#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; #define min(a,b) (a>b?b:a) #define max(a,b) (a>b?a:b) #define mem(a,num) memset(a,num,sizeof(a)) #define inf(a,n) fill(a,a+n,0x3f3f3f3f) int exgcd(int a,int b,int &x,int &y) { if(b==0) { x=1; y=0; return a; } int r=exgcd(b,a%b,x,y); int t=x; x=y; y=t-a/b*y; return r; } int sum[100005]; int T[100005]; int main() { ios::sync_with_stdio(false); int n; string a; while(cin>>n) { cin>>a; int len=a.length(); sum[0]=1;T[0]=1; int x,y; for(int i=0;i>c>>d; cout<