纪念——代码首次达到近50K(更新:78.8K 2019行)
#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行)的更多相关文章
- sphinx通过增量索引实现近实时更新
一.sphinx增量索引实现近实时更新设置 数据库中的已有数据很大,又不断有新数据加入到数据库中,也希望能够检索到.全部重新建立索引很消耗资源,因为我们需要更新的数据相比较而言很少. 例如.原来的数据 ...
- T-SQL openquery 删除报错 “键列信息不足或不正确。更新影响到多行”
DELETE OPENQUERY (VERYEAST_MAIN_MYSQL_CONN, 'SELECT college_userid FROM college_student_information ...
- ASP.NET网页动态添加、更新或删除数据行
ASP.NET网页动态添加.更新或删除数据行 看过此篇<ASP.NET网页动态添加数据行> http://www.cnblogs.com/insus/p/3247935.html的网友,也 ...
- 【sql server】"已更新或删除的行值要么不能使该行成为唯一行,要么改变了多个行" 解决方案
#事故现场: 1.在手动修改某表中数据是,出现如下错误提示: 已更新或删除的行值要么不能使该行成为唯一行,要么改变了多个行 2.表结构及数据: #解决方法: 1.原因分析:提示被删除的行不是唯一行, ...
- iOS开发之一句代码检测APP版本的更新
提示更新效果图如下,当然也是可以自定义类似与AlertView相似的自定义view,如京东.网易云音乐都是自定义了这种提示框的view.以下只展示,从App Store获取到app信息.并解析app信 ...
- 怎样用git上传代码到github以及如何更新代码
上传代码: 1.进入指定文件夹: cd 指定文件夹 2.初始化git仓库: git init 3.将项目所有文件添加到暂存区: git add . 4.提交到仓库: git commit -m &qu ...
- Fastjson 爆出远程代码执行高危漏洞,更新版本已修复
fastjson近日曝出代码执行漏洞,恶意用户可利用此漏洞进行远程代码执行,入侵服务器,漏洞评级为“高危”. 基本介绍fastjson 是一个性能很好的 Java 语言实现的 JSON 解析器和生成器 ...
- 代码反向生成数据库注释更新sql
原理 通过反射实体所在程序集,得到枚举值列表,再通过sql获取数据库表结构,两者拼接成sql. 规范 实体枚举字段最好也加上Description特性,方便多次更新: 代码 实体定义 public p ...
- win系统下git代码批量克隆,批量更新
@REM 根据实际情况设置GIT路径及本地仓库地址 set path=%path%;"D:\Program Files\Git\cmd" set project_path=F:\g ...
随机推荐
- 对this的理解与总结
this既不指向函数自身,也不指向函数的词法作用域!它指向谁完全取决于它在哪里被调用,被谁调用! 绑定规则 总体来说,this的绑定规则有: 默认绑定(严格模式/非严格模式) 隐式绑定 显式绑定 ne ...
- sql中on的连接条件与where的区别
left join [表名] on [条件] where [条件] --on表示连接条件 --where表示对结果的过滤条件 两者不尽相同,使用时需注意 例如: select * from tabl ...
- 廖雪峰Java15JDBC编程-1关系数据库基础-1关系数据库简介
1.数据库 1.1 定义 数据库是按照数据结构来组合.存储和管理数据的软件. 1.2 数据库模型 数据库有层次模型.网状模型.关系模型三种模型. 2 关系数据库 关系数据库是建立在关系模型上的数据库, ...
- token 与 基于JWT的Token认证
支持跨域访问,无状态认证 token特点 支持跨域访问: Cookie是不允许垮域访问的,这一点对Token机制是不存在的,前提是传输的用户认证信息通过HTTP头传输 无状态(也称:服务端可扩展行): ...
- Serverless Kubernetes全面升级2.0架构:支持多命名空间、RBAC、CRD、PV/PVC等功能
Serverless Kubernetes概述: 阿里云Serverless Kubernetes容器服务最新开放香港.新加坡.悉尼区域,同时全面开放2.0架构,帮助用户更加便捷.轻松地步入“以应用为 ...
- strict
strict为3.2.3新增连贯操作,用于设置数据写入和查询是否严格检查是否存在字段.默认情况下不合法数据字段自动删除,如果设置了严格检查则会抛出异常. 例如: $model->strict(t ...
- React中的表单应用
React中的表单应用 用户在表单填入的内容,属于用户跟组件的互动,所以不能用this.props读取. var Input = React.createClass({ //初始化组件数据 getIn ...
- Python(三)基础篇之「模块&面向对象编程」
[笔记]Python(三)基础篇之「模块&面向对象编程」 2016-12-07 ZOE 编程之魅 Python Notes: ★ 如果你是第一次阅读,推荐先浏览:[重要公告]文章更新. ...
- Spring MVC(十一)--使用字符串实现重定向
Spring MVC中有两种重定向方式: 通过返回字符串,字符串必须以redirect:开头: 通过返回ModelAndView: 重定向的时候如果需要给重定向目标方法传参数,要分字符串参数和pojo ...
- PAT甲级——A1101 Quick Sort
There is a classical process named partition in the famous quick sort algorithm. In this process we ...