#include #include using namespace std; typedef long long ll; typedef string str; #define INF_LL ((1LL<<63)-1) #define MOD 998244353 int main() { ll N; cin >> N; vector A(N), B(N); for(ll i=0; i> A[i]; /*} for(ll i=0; i> temp; if(temp == "X") B[i] = -1; else if(temp.back() == 'X') B[i] = -2; else B[i] = stoll(temp); } const ll MAX_K = 9, MAX_A = 5, MAX_B = 34; ll nonX_freq_table[MAX_A][MAX_B] = {{}}; ll X_freq_table[MAX_A] = {}; for(ll i=0; i= 0) nonX_freq_table[A[i]][B[i]]++; } ll modinv_table[MAX_K]; modinv_table[0] = 0; for(ll i=1; i=0; k--){ for(ll a=0; a