# coding: utf-8 M=998244353 N,Q=map(int,input().split()) S=list(input()) for q in range(Q): query=[int(_)for _ in input().split()] if query[0]==1: i=query[1]-1 if S[i]=='0': S[i]='1' elif S[i]=='1': S[i]='0' elif query[0]==2: L=query[1]-1 R=query[2]-1 A=0 for l in range(L,R): for r in range(l+2,R+2): A+=S[l:r].count('0')*S[l:r].count('1') A%=M print(A)