Easy Queries

This task is very simple. You are given a binary string (i.e. a string consisting of digits ‘0’ and ‘1’) of length n. The digits are numbered from the left to the right starting with 1. Now you have to execute m queries of two types on this string of the following form:

This is a companion discussion topic for the original entry at https://toph.co/p/easy-queries