#include<bits/stdc++.h>
#define re register
#define F(A) for(re int (A)=1;(A)<=8;++(A))
using namespace std;
int n,mi[],sp[],sa[],kn[],MI,SP,SA,KN;
double f[][][][][],g[][];
double ANS,mig[],spe[],san[],kno[];
char s[],s1[],s2[],s3[],s4[];
double pre[][],suf[][];
void addmi(int id,int val,double p){
F(i) F(j) F(k) F(l){
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void addsp(int id,int val,double p){
F(i) F(j) F(k) F(l){
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void addsa(int id,int val,double p){
F(i) F(j) F(k) F(l){
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void addkn(int id,int val,double p){
F(i) F(j) F(k) F(l){
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void mimixd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void mispxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void misaxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void miknxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void spmixd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void spspxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void spsaxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void spknxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void samixd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void saspxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void sasaxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void saknxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void knmixd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void knspxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void knsaxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void knknxd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void mimix(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void mispx(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void misax(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void miknx(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void spmix(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void spspx(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void spsax(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void spknx(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void samix(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void saspx(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void sasax(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void saknx(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void knmix(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void knspx(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void knsax(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void knknx(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void mimidd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void mispdd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void misadd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void mikndd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void spmidd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void spspdd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void spsadd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void spkndd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void samidd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void saspdd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void sasadd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void sakndd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void knmidd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void knspdd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void knsadd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void knkndd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
} void mimid(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void mispd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void misad(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void miknd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void spmid(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void spspd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void spsad(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void spknd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void samid(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void saspd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void sasad(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void saknd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void knmid(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
void knspd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
void knsad(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
void knknd(int id,int lim,int val){
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
void mimixdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void mispxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void misaxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void miknxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spmixdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spspxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spsaxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spknxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void samixdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void saspxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void sasaxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void saknxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knmixdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knspxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knsaxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knknxdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void mimixw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void mispxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void misaxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void miknxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spmixw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spspxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spsaxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spknxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void samixw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void saspxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void sasaxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void saknxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knmixw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knspxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knsaxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knknxw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void mimiddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void mispddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void misaddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void miknddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spmiddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spspddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spsaddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spknddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void samiddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void saspddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void sasaddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void saknddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knmiddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knspddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knsaddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knknddw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void mimidw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void mispdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void misadw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void mikndw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spmidw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spspdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spsadw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void spkndw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void samidw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void saspdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void sasadw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void sakndw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knmidw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knspdw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knsadw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
void knkndw(int id,int lim,int val){
re int flag=(val<)?-:;
F(i) F(j) F(k) F(l){
re double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(re int q=;q<=;++q){
re double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
signed main(){
scanf("%s%d",s+,&MI);F(i) mi[i]=s[i]-'';
scanf("%s%d",s+,&SP);F(i) sp[i]=s[i]-'';
scanf("%s%d",s+,&SA);F(i) sa[i]=s[i]-'';
scanf("%s%d",s+,&KN);F(i) kn[i]=s[i]-'';
f[][MI][SP][SA][KN]=1.0;
scanf("%d",&n); g[][]=1.0;
for(re int i=;i<;++i)
for(re int j=;j<=;++j){
g[i+][j+]+=g[i][j]*1.0/3.0;
g[i+][j+]+=g[i][j]*1.0/3.0;
g[i+][j+]+=g[i][j]*1.0/3.0;
}
for(re int i=;i<=;++i){
pre[i][]=g[i][];
for(re int j=;j<=;++j)
pre[i][j]=g[i][j]+pre[i][j-];
}
for(re int i=;i>=;--i){
suf[i][]=g[i][];
for(re int j=;j>=;--j)
suf[i][j]=g[i][j]+suf[i][j+];
}
for(re int id=;id<=n;++id){
scanf("%s%s",s1+,s2+);
if(s2[]=='+'||s2[]=='-'){
re int val=s2[]-'';
if(s2[]=='-') val=-val;
if(s2[]=='?'){
re int dat=abs(val);
re int flag=(s2[]=='-')?-:;
for(re int i=;i<=;++i){
if(s1[]=='i') addmi(id,i*flag,g[dat][i]);
if(s1[]=='p') addsp(id,i*flag,g[dat][i]);
if(s1[]=='a') addsa(id,i*flag,g[dat][i]);
if(s1[]=='n') addkn(id,i*flag,g[dat][i]);
}
}
else{
if(s1[]=='i') addmi(id,val,);
if(s1[]=='p') addsp(id,val,);
if(s1[]=='a') addsa(id,val,);
if(s1[]=='n') addkn(id,val,);
}
continue;
}
else if(s2[]=='>'||s2[]=='<'){
re int dat;
scanf("%d%s%s",&dat,s3+,s4+);
re int val=s4[]-'';
re int flag=(s4[]=='-')?-:;
if(s4[]=='?'){
if(s2[]=='>'&&s2[]=='='){
if(s1[]=='i'){
if(s3[]=='i') mimiddw(id,dat,val*flag);
if(s3[]=='p') mispddw(id,dat,val*flag);
if(s3[]=='a') misaddw(id,dat,val*flag);
if(s3[]=='n') miknddw(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmiddw(id,dat,val*flag);
if(s3[]=='p') spspddw(id,dat,val*flag);
if(s3[]=='a') spsaddw(id,dat,val*flag);
if(s3[]=='n') spknddw(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samiddw(id,dat,val*flag);
if(s3[]=='p') saspddw(id,dat,val*flag);
if(s3[]=='a') sasaddw(id,dat,val*flag);
if(s3[]=='n') saknddw(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmiddw(id,dat,val*flag);
if(s3[]=='p') knspddw(id,dat,val*flag);
if(s3[]=='a') knsaddw(id,dat,val*flag);
if(s3[]=='n') knknddw(id,dat,val*flag);
continue;
}
}
else if(s2[]=='<'&&s2[]=='='){
if(s1[]=='i'){
if(s3[]=='i') mimixdw(id,dat,val*flag);
if(s3[]=='p') mispxdw(id,dat,val*flag);
if(s3[]=='a') misaxdw(id,dat,val*flag);
if(s3[]=='n') miknxdw(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmixdw(id,dat,val*flag);
if(s3[]=='p') spspxdw(id,dat,val*flag);
if(s3[]=='a') spsaxdw(id,dat,val*flag);
if(s3[]=='n') spknxdw(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samixdw(id,dat,val*flag);
if(s3[]=='p') saspxdw(id,dat,val*flag);
if(s3[]=='a') sasaxdw(id,dat,val*flag);
if(s3[]=='n') saknxdw(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmixdw(id,dat,val*flag);
if(s3[]=='p') knspxdw(id,dat,val*flag);
if(s3[]=='a') knsaxdw(id,dat,val*flag);
if(s3[]=='n') knknxdw(id,dat,val*flag);
continue;
}
}
else if(s2[]=='>'){
if(s1[]=='i'){
if(s3[]=='i') mimidw(id,dat,val*flag);
if(s3[]=='p') mispdw(id,dat,val*flag);
if(s3[]=='a') misadw(id,dat,val*flag);
if(s3[]=='n') mikndw(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmidw(id,dat,val*flag);
if(s3[]=='p') spspdw(id,dat,val*flag);
if(s3[]=='a') spsadw(id,dat,val*flag);
if(s3[]=='n') spkndw(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samidw(id,dat,val*flag);
if(s3[]=='p') saspdw(id,dat,val*flag);
if(s3[]=='a') sasadw(id,dat,val*flag);
if(s3[]=='n') sakndw(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmidw(id,dat,val*flag);
if(s3[]=='p') knspdw(id,dat,val*flag);
if(s3[]=='a') knsadw(id,dat,val*flag);
if(s3[]=='n') knkndw(id,dat,val*flag);
continue;
}
}
else if(s2[]=='<'){
if(s1[]=='i'){
if(s3[]=='i') mimixw(id,dat,val*flag);
if(s3[]=='p') mispxw(id,dat,val*flag);
if(s3[]=='a') misaxw(id,dat,val*flag);
if(s3[]=='n') miknxw(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmixw(id,dat,val*flag);
if(s3[]=='p') spspxw(id,dat,val*flag);
if(s3[]=='a') spsaxw(id,dat,val*flag);
if(s3[]=='n') spknxw(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samixw(id,dat,val*flag);
if(s3[]=='p') saspxw(id,dat,val*flag);
if(s3[]=='a') sasaxw(id,dat,val*flag);
if(s3[]=='n') saknxw(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmixw(id,dat,val*flag);
if(s3[]=='p') knspxw(id,dat,val*flag);
if(s3[]=='a') knsaxw(id,dat,val*flag);
if(s3[]=='n') knknxw(id,dat,val*flag);
continue;
}
}
}
else{
if(s2[]=='>'&&s2[]=='='){
if(s1[]=='i'){
if(s3[]=='i') mimidd(id,dat,val*flag);
if(s3[]=='p') mispdd(id,dat,val*flag);
if(s3[]=='a') misadd(id,dat,val*flag);
if(s3[]=='n') mikndd(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmidd(id,dat,val*flag);
if(s3[]=='p') spspdd(id,dat,val*flag);
if(s3[]=='a') spsadd(id,dat,val*flag);
if(s3[]=='n') spkndd(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samidd(id,dat,val*flag);
if(s3[]=='p') saspdd(id,dat,val*flag);
if(s3[]=='a') sasadd(id,dat,val*flag);
if(s3[]=='n') sakndd(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmidd(id,dat,val*flag);
if(s3[]=='p') knspdd(id,dat,val*flag);
if(s3[]=='a') knsadd(id,dat,val*flag);
if(s3[]=='n') knkndd(id,dat,val*flag);
continue;
}
}
else if(s2[]=='<'&&s2[]=='='){
if(s1[]=='i'){
if(s3[]=='i') mimixd(id,dat,val*flag);
if(s3[]=='p') mispxd(id,dat,val*flag);
if(s3[]=='a') misaxd(id,dat,val*flag);
if(s3[]=='n') miknxd(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmixd(id,dat,val*flag);
if(s3[]=='p') spspxd(id,dat,val*flag);
if(s3[]=='a') spsaxd(id,dat,val*flag);
if(s3[]=='n') spknxd(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samixd(id,dat,val*flag);
if(s3[]=='p') saspxd(id,dat,val*flag);
if(s3[]=='a') sasaxd(id,dat,val*flag);
if(s3[]=='n') saknxd(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmixd(id,dat,val*flag);
if(s3[]=='p') knspxd(id,dat,val*flag);
if(s3[]=='a') knsaxd(id,dat,val*flag);
if(s3[]=='n') knknxd(id,dat,val*flag);
continue;
}
}
else if(s2[]=='>'){
if(s1[]=='i'){
if(s3[]=='i') mimid(id,dat,val*flag);
if(s3[]=='p') mispd(id,dat,val*flag);
if(s3[]=='a') misad(id,dat,val*flag);
if(s3[]=='n') miknd(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmid(id,dat,val*flag);
if(s3[]=='p') spspd(id,dat,val*flag);
if(s3[]=='a') spsad(id,dat,val*flag);
if(s3[]=='n') spknd(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samid(id,dat,val*flag);
if(s3[]=='p') saspd(id,dat,val*flag);
if(s3[]=='a') sasad(id,dat,val*flag);
if(s3[]=='n') saknd(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmid(id,dat,val*flag);
if(s3[]=='p') knspd(id,dat,val*flag);
if(s3[]=='a') knsad(id,dat,val*flag);
if(s3[]=='n') knknd(id,dat,val*flag);
continue;
}
}
else if(s2[]=='<'){
if(s1[]=='i'){
if(s3[]=='i') mimix(id,dat,val*flag);
if(s3[]=='p') mispx(id,dat,val*flag);
if(s3[]=='a') misax(id,dat,val*flag);
if(s3[]=='n') miknx(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmix(id,dat,val*flag);
if(s3[]=='p') spspx(id,dat,val*flag);
if(s3[]=='a') spsax(id,dat,val*flag);
if(s3[]=='n') spknx(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samix(id,dat,val*flag);
if(s3[]=='p') saspx(id,dat,val*flag);
if(s3[]=='a') sasax(id,dat,val*flag);
if(s3[]=='n') saknx(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmix(id,dat,val*flag);
if(s3[]=='p') knspx(id,dat,val*flag);
if(s3[]=='a') knsax(id,dat,val*flag);
if(s3[]=='n') knknx(id,dat,val*flag);
continue;
}
}
}
}
}
printf("%.2lf\n",ANS*100.0);
F(i) F(j) F(k) F(l){
mig[mi[i]]+=f[n][i][j][k][l];
spe[sp[j]]+=f[n][i][j][k][l];
san[sa[k]]+=f[n][i][j][k][l];
kno[kn[l]]+=f[n][i][j][k][l];
}
F(i) printf("%.2lf ",mig[i]*100.0);puts("");
F(i) printf("%.2lf ",spe[i]*100.0);puts("");
F(i) printf("%.2lf ",san[i]*100.0);puts("");
F(i) printf("%.2lf ",kno[i]*100.0);puts("");
}
 #include<bits/stdc++.h>
using namespace std;
int n,mi[],sp[],sa[],kn[],MI,SP,SA,KN;
double f[][][][][],g[][];
double ANS,mig[],spe[],san[],kno[];
char s[],s1[],s2[],s3[],s4[];
double pre[][],suf[][];
inline void addmi(register int id,register int val,register double p){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void addsp(register int id,register int val,register double p){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void addsa(register int id,register int val,register double p){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void addkn(register int id,register int val,register double p){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void mimixd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void mispxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void misaxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void miknxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void spmixd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spspxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spsaxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spknxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void samixd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void saspxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void sasaxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void saknxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void knmixd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knspxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knsaxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knknxd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void mimix(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void mispx(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void misax(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void miknx(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void spmix(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spspx(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spsax(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spknx(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void samix(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void saspx(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void sasax(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void saknx(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void knmix(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knspx(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knsax(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knknx(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void mimidd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void mispdd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void misadd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void mikndd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void spmidd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spspdd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spsadd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spkndd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void samidd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void saspdd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void sasadd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void sakndd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void knmidd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knspdd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knsadd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knkndd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void mimid(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void mispd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void misad(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void miknd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void spmid(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spspd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spsad(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void spknd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void samid(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void saspd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void sasad(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void saknd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void knmid(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(i+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][min(,i+val)][j][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knspd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(j+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][min(,j+val)][k][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knsad(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(k+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][min(,k+val)][l]+=f[id-][i][j][k][l]*p;
}
}
inline void knknd(register int id,register int lim,register int val){
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
if(l+val<=) ANS+=f[id-][i][j][k][l]*p;
else f[id][i][j][k][min(,l+val)]+=f[id-][i][j][k][l]*p;
}
}
inline void mimixdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void mispxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void misaxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void miknxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spmixdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spspxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spsaxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spknxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void samixdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void saspxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void sasaxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void saknxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knmixdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knspxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knsaxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knknxdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void mimixw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void mispxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void misaxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void miknxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[mi[i]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spmixw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spspxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spsaxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spknxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sp[j]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void samixw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void saspxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void sasaxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void saknxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[sa[k]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knmixw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knspxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knsaxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knknxw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=pre[kn[l]][lim-];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void mimiddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void mispddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void misaddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void miknddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spmiddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spspddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spsaddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spknddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void samiddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void saspddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void sasaddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void saknddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knmiddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knspddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knsaddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knknddw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void mimidw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void mispdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void misadw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void mikndw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[mi[i]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spmidw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spspdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spsadw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void spkndw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sp[j]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void samidw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void saspdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void sasadw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void sakndw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[sa[k]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knmidw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(i+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][min(,i+q*flag)][j][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knspdw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(j+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][min(,j+q*flag)][k][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knsadw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(k+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][min(,k+q*flag)][l]+=f[id-][i][j][k][l]*p*gl;
}
}
}
inline void knkndw(register int id,register int lim,register int val){
register int flag=(val<)?-:;
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
register double p=suf[kn[l]][lim+];
f[id][i][j][k][l]+=f[id-][i][j][k][l]*(-p);
for(register int q=;q<=;++q){
register double gl=g[abs(val)][q];
if(l+q*flag<=) ANS+=f[id-][i][j][k][l]*p*gl;
else f[id][i][j][k][min(,l+q*flag)]+=f[id-][i][j][k][l]*p*gl;
}
}
}
signed main(){
scanf("%s%d",s+,&MI);for(register int i=;i<=;++i) mi[i]=s[i]-'';
scanf("%s%d",s+,&SP);for(register int i=;i<=;++i) sp[i]=s[i]-'';
scanf("%s%d",s+,&SA);for(register int i=;i<=;++i) sa[i]=s[i]-'';
scanf("%s%d",s+,&KN);for(register int i=;i<=;++i) kn[i]=s[i]-'';
f[][MI][SP][SA][KN]=1.0;
scanf("%d",&n); g[][]=1.0;
for(register int i=;i<;++i)
for(register int j=;j<=;++j){
g[i+][j+]+=g[i][j]*1.0/3.0;
g[i+][j+]+=g[i][j]*1.0/3.0;
g[i+][j+]+=g[i][j]*1.0/3.0;
}
for(register int i=;i<=;++i){
pre[i][]=g[i][];
for(register int j=;j<=;++j)
pre[i][j]=g[i][j]+pre[i][j-];
}
for(register int i=;i>=;--i){
suf[i][]=g[i][];
for(register int j=;j>=;--j)
suf[i][j]=g[i][j]+suf[i][j+];
}
for(register int id=;id<=n;++id){
scanf("%s%s",s1+,s2+);
if(s2[]=='+'||s2[]=='-'){
register int val=s2[]-'';
if(s2[]=='-') val=-val;
if(s2[]=='?'){
register int dat=abs(val);
register int flag=(s2[]=='-')?-:;
for(register int i=;i<=;++i){
if(s1[]=='i') addmi(id,i*flag,g[dat][i]);
if(s1[]=='p') addsp(id,i*flag,g[dat][i]);
if(s1[]=='a') addsa(id,i*flag,g[dat][i]);
if(s1[]=='n') addkn(id,i*flag,g[dat][i]);
}
}
else{
if(s1[]=='i') addmi(id,val,);
if(s1[]=='p') addsp(id,val,);
if(s1[]=='a') addsa(id,val,);
if(s1[]=='n') addkn(id,val,);
}
continue;
}
else if(s2[]=='>'||s2[]=='<'){
register int dat;
scanf("%d%s%s",&dat,s3+,s4+);
register int val=s4[]-'';
register int flag=(s4[]=='-')?-:;
if(s4[]=='?'){
if(s2[]=='>'&&s2[]=='='){
if(s1[]=='i'){
if(s3[]=='i') mimiddw(id,dat,val*flag);
if(s3[]=='p') mispddw(id,dat,val*flag);
if(s3[]=='a') misaddw(id,dat,val*flag);
if(s3[]=='n') miknddw(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmiddw(id,dat,val*flag);
if(s3[]=='p') spspddw(id,dat,val*flag);
if(s3[]=='a') spsaddw(id,dat,val*flag);
if(s3[]=='n') spknddw(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samiddw(id,dat,val*flag);
if(s3[]=='p') saspddw(id,dat,val*flag);
if(s3[]=='a') sasaddw(id,dat,val*flag);
if(s3[]=='n') saknddw(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmiddw(id,dat,val*flag);
if(s3[]=='p') knspddw(id,dat,val*flag);
if(s3[]=='a') knsaddw(id,dat,val*flag);
if(s3[]=='n') knknddw(id,dat,val*flag);
continue;
}
}
else if(s2[]=='<'&&s2[]=='='){
if(s1[]=='i'){
if(s3[]=='i') mimixdw(id,dat,val*flag);
if(s3[]=='p') mispxdw(id,dat,val*flag);
if(s3[]=='a') misaxdw(id,dat,val*flag);
if(s3[]=='n') miknxdw(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmixdw(id,dat,val*flag);
if(s3[]=='p') spspxdw(id,dat,val*flag);
if(s3[]=='a') spsaxdw(id,dat,val*flag);
if(s3[]=='n') spknxdw(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samixdw(id,dat,val*flag);
if(s3[]=='p') saspxdw(id,dat,val*flag);
if(s3[]=='a') sasaxdw(id,dat,val*flag);
if(s3[]=='n') saknxdw(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmixdw(id,dat,val*flag);
if(s3[]=='p') knspxdw(id,dat,val*flag);
if(s3[]=='a') knsaxdw(id,dat,val*flag);
if(s3[]=='n') knknxdw(id,dat,val*flag);
continue;
}
}
else if(s2[]=='>'){
if(s1[]=='i'){
if(s3[]=='i') mimidw(id,dat,val*flag);
if(s3[]=='p') mispdw(id,dat,val*flag);
if(s3[]=='a') misadw(id,dat,val*flag);
if(s3[]=='n') mikndw(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmidw(id,dat,val*flag);
if(s3[]=='p') spspdw(id,dat,val*flag);
if(s3[]=='a') spsadw(id,dat,val*flag);
if(s3[]=='n') spkndw(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samidw(id,dat,val*flag);
if(s3[]=='p') saspdw(id,dat,val*flag);
if(s3[]=='a') sasadw(id,dat,val*flag);
if(s3[]=='n') sakndw(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmidw(id,dat,val*flag);
if(s3[]=='p') knspdw(id,dat,val*flag);
if(s3[]=='a') knsadw(id,dat,val*flag);
if(s3[]=='n') knkndw(id,dat,val*flag);
continue;
}
}
else if(s2[]=='<'){
if(s1[]=='i'){
if(s3[]=='i') mimixw(id,dat,val*flag);
if(s3[]=='p') mispxw(id,dat,val*flag);
if(s3[]=='a') misaxw(id,dat,val*flag);
if(s3[]=='n') miknxw(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmixw(id,dat,val*flag);
if(s3[]=='p') spspxw(id,dat,val*flag);
if(s3[]=='a') spsaxw(id,dat,val*flag);
if(s3[]=='n') spknxw(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samixw(id,dat,val*flag);
if(s3[]=='p') saspxw(id,dat,val*flag);
if(s3[]=='a') sasaxw(id,dat,val*flag);
if(s3[]=='n') saknxw(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmixw(id,dat,val*flag);
if(s3[]=='p') knspxw(id,dat,val*flag);
if(s3[]=='a') knsaxw(id,dat,val*flag);
if(s3[]=='n') knknxw(id,dat,val*flag);
continue;
}
}
}
else{
if(s2[]=='>'&&s2[]=='='){
if(s1[]=='i'){
if(s3[]=='i') mimidd(id,dat,val*flag);
if(s3[]=='p') mispdd(id,dat,val*flag);
if(s3[]=='a') misadd(id,dat,val*flag);
if(s3[]=='n') mikndd(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmidd(id,dat,val*flag);
if(s3[]=='p') spspdd(id,dat,val*flag);
if(s3[]=='a') spsadd(id,dat,val*flag);
if(s3[]=='n') spkndd(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samidd(id,dat,val*flag);
if(s3[]=='p') saspdd(id,dat,val*flag);
if(s3[]=='a') sasadd(id,dat,val*flag);
if(s3[]=='n') sakndd(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmidd(id,dat,val*flag);
if(s3[]=='p') knspdd(id,dat,val*flag);
if(s3[]=='a') knsadd(id,dat,val*flag);
if(s3[]=='n') knkndd(id,dat,val*flag);
continue;
}
}
else if(s2[]=='<'&&s2[]=='='){
if(s1[]=='i'){
if(s3[]=='i') mimixd(id,dat,val*flag);
if(s3[]=='p') mispxd(id,dat,val*flag);
if(s3[]=='a') misaxd(id,dat,val*flag);
if(s3[]=='n') miknxd(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmixd(id,dat,val*flag);
if(s3[]=='p') spspxd(id,dat,val*flag);
if(s3[]=='a') spsaxd(id,dat,val*flag);
if(s3[]=='n') spknxd(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samixd(id,dat,val*flag);
if(s3[]=='p') saspxd(id,dat,val*flag);
if(s3[]=='a') sasaxd(id,dat,val*flag);
if(s3[]=='n') saknxd(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmixd(id,dat,val*flag);
if(s3[]=='p') knspxd(id,dat,val*flag);
if(s3[]=='a') knsaxd(id,dat,val*flag);
if(s3[]=='n') knknxd(id,dat,val*flag);
continue;
}
}
else if(s2[]=='>'){
if(s1[]=='i'){
if(s3[]=='i') mimid(id,dat,val*flag);
if(s3[]=='p') mispd(id,dat,val*flag);
if(s3[]=='a') misad(id,dat,val*flag);
if(s3[]=='n') miknd(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmid(id,dat,val*flag);
if(s3[]=='p') spspd(id,dat,val*flag);
if(s3[]=='a') spsad(id,dat,val*flag);
if(s3[]=='n') spknd(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samid(id,dat,val*flag);
if(s3[]=='p') saspd(id,dat,val*flag);
if(s3[]=='a') sasad(id,dat,val*flag);
if(s3[]=='n') saknd(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmid(id,dat,val*flag);
if(s3[]=='p') knspd(id,dat,val*flag);
if(s3[]=='a') knsad(id,dat,val*flag);
if(s3[]=='n') knknd(id,dat,val*flag);
continue;
}
}
else if(s2[]=='<'){
if(s1[]=='i'){
if(s3[]=='i') mimix(id,dat,val*flag);
if(s3[]=='p') mispx(id,dat,val*flag);
if(s3[]=='a') misax(id,dat,val*flag);
if(s3[]=='n') miknx(id,dat,val*flag);
continue;
}
if(s1[]=='p'){
if(s3[]=='i') spmix(id,dat,val*flag);
if(s3[]=='p') spspx(id,dat,val*flag);
if(s3[]=='a') spsax(id,dat,val*flag);
if(s3[]=='n') spknx(id,dat,val*flag);
continue;
}
if(s1[]=='a'){
if(s3[]=='i') samix(id,dat,val*flag);
if(s3[]=='p') saspx(id,dat,val*flag);
if(s3[]=='a') sasax(id,dat,val*flag);
if(s3[]=='n') saknx(id,dat,val*flag);
continue;
}
if(s1[]=='n'){
if(s3[]=='i') knmix(id,dat,val*flag);
if(s3[]=='p') knspx(id,dat,val*flag);
if(s3[]=='a') knsax(id,dat,val*flag);
if(s3[]=='n') knknx(id,dat,val*flag);
continue;
}
}
}
}
}
printf("%.2lf\n",ANS*100.0);
for(register int i=;i<=;++i)
for(register int j=;j<=;++j)
for(register int k=;k<=;++k)
for(register int l=;l<=;++l){
mig[mi[i]]+=f[n][i][j][k][l];
spe[sp[j]]+=f[n][i][j][k][l];
san[sa[k]]+=f[n][i][j][k][l];
kno[kn[l]]+=f[n][i][j][k][l];
}
for(register int i=;i<=;++i) printf("%.2lf ",mig[i]*100.0); puts("");
for(register int i=;i<=;++i) printf("%.2lf ",spe[i]*100.0); puts("");
for(register int i=;i<=;++i) printf("%.2lf ",san[i]*100.0); puts("");
for(register int i=;i<=;++i) printf("%.2lf ",kno[i]*100.0); puts("");
}

纪念——代码首次达到近50K(更新:78.8K 2019行)的更多相关文章

  1. sphinx通过增量索引实现近实时更新

    一.sphinx增量索引实现近实时更新设置 数据库中的已有数据很大,又不断有新数据加入到数据库中,也希望能够检索到.全部重新建立索引很消耗资源,因为我们需要更新的数据相比较而言很少. 例如.原来的数据 ...

  2. T-SQL openquery 删除报错 “键列信息不足或不正确。更新影响到多行”

    DELETE OPENQUERY (VERYEAST_MAIN_MYSQL_CONN, 'SELECT college_userid FROM college_student_information ...

  3. ASP.NET网页动态添加、更新或删除数据行

    ASP.NET网页动态添加.更新或删除数据行 看过此篇<ASP.NET网页动态添加数据行> http://www.cnblogs.com/insus/p/3247935.html的网友,也 ...

  4. 【sql server】"已更新或删除的行值要么不能使该行成为唯一行,要么改变了多个行" 解决方案

    #事故现场: 1.在手动修改某表中数据是,出现如下错误提示:  已更新或删除的行值要么不能使该行成为唯一行,要么改变了多个行 2.表结构及数据: #解决方法: 1.原因分析:提示被删除的行不是唯一行, ...

  5. iOS开发之一句代码检测APP版本的更新

    提示更新效果图如下,当然也是可以自定义类似与AlertView相似的自定义view,如京东.网易云音乐都是自定义了这种提示框的view.以下只展示,从App Store获取到app信息.并解析app信 ...

  6. 怎样用git上传代码到github以及如何更新代码

    上传代码: 1.进入指定文件夹: cd 指定文件夹 2.初始化git仓库: git init 3.将项目所有文件添加到暂存区: git add . 4.提交到仓库: git commit -m &qu ...

  7. Fastjson 爆出远程代码执行高危漏洞,更新版本已修复

    fastjson近日曝出代码执行漏洞,恶意用户可利用此漏洞进行远程代码执行,入侵服务器,漏洞评级为“高危”. 基本介绍fastjson 是一个性能很好的 Java 语言实现的 JSON 解析器和生成器 ...

  8. 代码反向生成数据库注释更新sql

    原理 通过反射实体所在程序集,得到枚举值列表,再通过sql获取数据库表结构,两者拼接成sql. 规范 实体枚举字段最好也加上Description特性,方便多次更新: 代码 实体定义 public p ...

  9. win系统下git代码批量克隆,批量更新

    @REM 根据实际情况设置GIT路径及本地仓库地址 set path=%path%;"D:\Program Files\Git\cmd" set project_path=F:\g ...

随机推荐

  1. gdb调试工具的使用

    GDB是一个由GNU开源组织发布的.UNIX/LINUX操作系统下的.基于命令行的.功能强大的程序调试工具. GDB中的命令固然很多,但我们只需掌握其中十个左右的命令,就大致可以完成日常的基本的程序调 ...

  2. Python全栈开发:css引入方式

    css的四种引入方式: 1.行内式 行内式是在标记的style属性中设定CSS样式.这种方式没有体现出CSS的优势,不推荐使用. <p style="color: red;backgr ...

  3. python+selenium中webdriver相关资源

    Chrome chrome的webdriver :  http://chromedriver.storage.googleapis.com/index.html chrome的webdriver需要对 ...

  4. CSS3 学习笔记(边框 背景 字体 图片 旋转等)

    边框 盒子圆角 border-radius:5px / 20%: border-radius:5px 4px 3px 2px; 左上,右上,右下,左下 盒子阴影 box-shadow:box-shad ...

  5. 廖雪峰Java11多线程编程-3高级concurrent包-5Atomic

    Atomic java.util.concurrent.atomic提供了一组原子类型操作: 如AtomicInteger提供了 int addAndGet(int delta) int increm ...

  6. SpringCloud搭建分布式配置中心(基于git)

    1.简介 Spring Cloud Config.它用来为分布式系统中的基础设施和微服务提供集中化的外部配置支持,分为服务端和客户端两个部分. 其中服务端也称为分布式配置中心,他是独立的微服务应用,用 ...

  7. C++萃取技术的一个简单初探

    首先本文并不是讲解C++萃取技术,关于C++的萃取技术网上有很多文章,推荐http://www.cppblog.com/woaidongmao/archive/2008/11/09/66387.htm ...

  8. 要原版 jdk-6u14-windows-i586.exe

    http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html#j ...

  9. koa2 安装环境

    1.安装koa2 npm install koa@2 -g 2.创建项目 (1)安装koa2生成器 npm install koa-generator -g (2)koa2生成一个test项目 koa ...

  10. PAT甲级——【牛客练习A1004】

    题目描述 An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For ex ...