#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl "\n"
#define MOD 1000000007
#define INF LLONG_MAX
#define MINF LLONG_MIN
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>

int pow(int x, int y, int mod) {
    int temp;
    if (y == 0)
        return 1;

    temp = (pow(x, y / 2, mod)) % mod;

    if (y % 2 == 0)
        return (temp * temp) % mod;
    else
        return (((x * temp) % mod) * temp) % mod;
}

int score(vector<int> &v) {

    int ans = 0;

    for(int i = 1; i <= 9; i ++) {

        ans += i * pow(10, v[i]);
    }

    return ans;
}
void solve(int tno) {

    int k; cin >> k;

    vector<int> cards(10, k);
    string S, T;
    cin >> S >> T;

    vector<int> t(10, 0), a(10, 0);

    for(char ch : S) {

        if(ch == '#')
            continue;
        t[ch - '0'] ++;
        cards[ch - '0'] --;
    }

    for(char ch : T) {

        if(ch == '#')
            continue;
        a[ch - '0'] ++;
        cards[ch - '0'] --;
    }

    int taka = 0, aoki = 0;
    for(int i = 1; i <= 9; i ++) {
        for(int j = 1; j <= 9; j ++) {

            if(i == j || cards[i] == 0 || cards[j] == 0)
                continue;

            t[i] ++;
            a[j] ++;

            if(score(t) > score(a))
                taka += cards[i] * cards[j];
            else
                aoki += cards[i] * cards[j];

            t[i] --;
            a[j] --;
        }
    }

    for(int i = 1; i <= 9; i ++) {

        if(cards[i] < 2)
            continue;

        t[i] ++;
        a[i] ++;

        if(score(t) > score(a)) {
            taka += cards[i] * (cards[i] - 1);
        }
        else {
            aoki += cards[i] * (cards[i] - 1);
        }

        t[i] --;
        a[i] --;
    }
    // cout << taka << ' ' << (taka + aoki) << endl;
    printf("%.15lf\n", (taka * 1.0) / (taka + aoki));
}

int32_t main() {

    FASTIO

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    for (int i = 1; i <= t; i ++)
        solve(i);
}

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll>
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=1e9+7;
ll max(ll a,ll b) {return ((a>b)?a:b);}
ll min(ll a,ll b) {return ((a>b)?b:a);}
vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
void sol(void)
{
cin>>n>>m;
string s[n];
vector<int> r[n];
vector<int> c[m];
int rp[n]={0};
int colp[m]={0};
int cnt=0;
for(int i=0;i<n;i++)
{
cin>>s[i];
for(int j=0;j<m;j++)
{
if(s[i][j]=='#')
r[i].pb(j),c[j].pb(i);
else
cnt++;
}
}
ll ans=0;
ll cc;
temp=power(2,cnt);
for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {
        if(s[i][j]=='#')
        continue;
        while(rp[i]<r[i].size() && r[i][rp[i]]<j)
        rp[i]++;
        int right=((rp[i]<r[i].size())?r[i][rp[i]]:m);
        int left=-1;
        if(rp[i]>0)
        left=r[i][rp[i]-1];
        ll calc=temp+mod;
        cc=right-left-1;
        int up=-1;
        int down=n;
        while(colp[j]<c[j].size() && c[j][colp[j]]<i)
        colp[j]++;
        if(colp[j]<c[j].size())
        down=c[j][colp[j]];
        if(colp[j]>0)
        up=c[j][colp[j]-1];
        cc+=down-up-1;
        cc--;
        ll calc2=(power(2,cnt-cc));
        calc-=calc2;
        calc%=mod;
        ans+=calc;
        ans%=mod;
    }
}
cout<<ans;
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


/*
    author : aryan57
    created : 29-May-2021 18:09:38 IST
*/
#include <bits/stdc++.h>
using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define int long long
#define X first
#define Y second
#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define F(i, a, b) for (int i = a; i <= b; i++)
#define RF(i, a, b) for (int i = a; i >= b; i--)

const int mxn = 1e5;
const long long INF = 2e18;
const int32_t M = 1000000007;
// const int32_t M = 998244353;
const long double pie = acos(-1);

void solve_LOG()
{
    int n;
    cin>>n;

    vector <int> v[3];

    F(i,0,2*n-1)
    {
        int a;
        cin>>a;

        char x;
        cin>>x;

        if(x=='R')v[0].push_back(a);
        if(x=='G')v[1].push_back(a);
        if(x=='B')v[2].push_back(a);
    }

    if(sz(v[0])%2==0 && sz(v[1])%2==0 && sz(v[2])%2==0)
    {
        cout<<0;
        cout<<"\n";
        return;
    }

    int x=-1;
    F(i,0,2)
    {
        if(sz(v[i])%2==0)
        {
            x=i;
            break;
        }
    }

    assert(x!=-1);

    if(x==1)
    {
        swap(v[1],v[2]);
    }
    if(x==0)
    {
        swap(v[0],v[2]);
    }

    sort(all(v[0]));
    sort(all(v[1]));

    int ans=INF;

    for(int x : v[0])
    {
        int pos=lower_bound(all(v[1]),x)-v[1].begin();

        F(i,pos-3,pos+3)
        {
            if(i<0 || i>=sz(v[1]))continue;
            ans=min(abs(x-v[1][i]),ans);
        }
    }

    assert(ans!=INF);

    vector<pair<int,int> > vec(sz(v[2]));
    int mnx=INF;
    int mnx_pos=-1;
    int mny=INF;
    int mny_pos=-1;
    F(j,0,sz(v[2])-1)
    {
        int pos=lower_bound(all(v[0]),v[2][j])-v[0].begin();
        int mn=INF;
        F(i,pos-3,pos+3)
        {
            if(i<0 || i>=sz(v[0]))continue;
            mn=min(abs(v[2][j]-v[0][i]),mn);
        }

        // assert(mn!=INF);
        vec[j].X=mn;

        if(mnx>mn)
        {
            mnx=mn;
            mnx_pos=j;
        }

        pos=lower_bound(all(v[1]),v[2][j])-v[1].begin();
        mn=INF;
        F(i,pos-3,pos+3)
        {
            if(i<0 || i>=sz(v[1]))continue;
            mn=min(abs(v[2][j]-v[1][i]),mn);
        }

        // assert(mn!=INF);
        vec[j].Y=mn;

        if(mny>mn)
        {
            mny=mn;
            mny_pos=j;
        }
    }

    if(mnx_pos!=mny_pos)
    {
        ans=min(ans,mnx+mny);
    }else
    {
        F(i,0,sz(vec)-1)
        {
            if(i!=mnx_pos)ans=min(ans,mnx+vec[i].Y);
            if(i!=mny_pos)ans=min(ans,mny+vec[i].X);
        }
    }

    cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
#ifdef ARYAN_SIEVE
    sieve();
#endif
#ifdef ARYAN_SEG_SIEVE
    segmented_sieve();
#endif
#ifdef ARYAN_FACT
    fact_init();
#endif
    // cout<<fixed<<setprecision(10);
    int _t=1;
    // cin>>_t;
    for (int i=1;i<=_t;i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve_LOG();
    }
    return 0;
}
//	parsed : 29-May-2021 18:09:30 IST

//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define uni(x) sort(all(x)),x.resize(unique(all(x))-x.begin());
#define GETPOS(c,x) (lower_bound(all(c),x)-c.begin())
#define lown1(x,val) low(in(x),val)-x
#define lowm1(x,val) low(im(x),val)-x
#define low1(x,nums,val) low(x+1,x+nums+1,val)-x
#define mst(x,val) memset((x),val,sizeof((x)))
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define far(i,V) for(auto &i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b))/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) ((x)&(-x))
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (((x)<0)?(x)%mo_num+mo_num:(x)%mo_num)
#define vc vector
#define vct vector<int>
#define SET set<int>
#define dq deque<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define Umap unordered_map<int,int>
#define P pair<int,int>
#define mk make_tuple
#define eps 1e-6
//Remember cancel"#define endl '\n'" in interactive questions or use "<<flush"
#define endl '\n'
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
//#define yn(key) out(key?"Yes":"No")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define ik(i,k) i+1,i+1+k
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define db double
#define ll long long
#define got(container,num) get<num-1>(container)
#define int long long
#define print(a,n) fun(i)cout<<a[i]<<(i!=n?' ':endl);
#define outcase(x) cout<<"Case #"<<(++case_of_T)<<": "<<(x)<<endl;
#define ptcase(x) printf("Case #%d: %d\n",++case_of_T,x);
#define plcase(x) printf("Case #%lld: %lld\n",++case_of_T,x);
using namespace std;
//Remember to cancel the line below and declare INT=INT_MAX/2; when you want to change long to int
const int INF=LLONG_MAX/4,SINF=0x3f3f3f3f,Lim=1<<20,MINF=LLONG_MAX;
//const int INF=INT_MAX/4,SINF=0x3f;
// use C:printf("%.16f", x);  ->  printf("%.10f", x); can accelerate the program
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//down up left right
const int maxn=1e6+1e5;
int mo_num=1e9+7;
//const int mo_num=998244353;
int n,m,t,a[maxn],b[maxn],ans,case_of_T;

void solve()
{
    cin>>n;
    fun(i)cin>>a[i];
    int now=0;
    fu(i,2,1000)
    {
        int num=0;
        fun(j)num+=a[j]%i==0;
        if(num>now)
        {
            now=num;ans=i;
        }
    }
    out(ans)
    return ;
}
main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
	T t=0;
	char k;
	bool vis=0;
	do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
	while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
	return vis?-t:t;
}
# define fre(k) freopen(k".in","r",stdin);freopen(k".out","w",stdout)
const int N=90;
ll fib[135],s;
vector<pair<int,int> >ans;
int main(){s=read;
	fib[1]=fib[0]=1;
	for(int i=2;i<=N;++i)fib[i]=fib[i-1]+fib[i-2];
	if(s==1)return printf("1\n1"),0;
	vector<int>ve;
	for(int i=N;i&&s;--i)
		if(fib[i]<=s){
			ve.push_back(i);
			s-=fib[i];
		}
	for(int i=1;i<ve.size();++i)
		if(ve[0]-ve[i]&1)
			ans.push_back(make_pair(ve[0]-ve[i],1));
		else ans.push_back(make_pair(ve[0]-ve[i],2));
	for(int i=1;i<ve[0];++i)
		ans.push_back(make_pair(i,i&1?4:3));
	ans.push_back(make_pair(-1,1));
	ans.push_back(make_pair(-1,2));
	sort(ans.begin(),ans.end());
	if(~ve[0]&1)
		for(int i=0;i<ans.size();++i)
			if(ans[i].second<=2)ans[i].second=3-ans[i].second;
			else ans[i].second=7-ans[i].second;
	cout<<ans.size()<<endl;ll l=0,r=0;
	for(int i=0;i<ans.size();++i)printf("%d\n",ans[i].second)/*,ans[i].second==1?++l:ans[i].second==2?++r:ans[i].second==3?l+=r:r+=l*/;
//	cout<<l<<' '<<r<<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 101;

int dp[N][N * N * N], cnt[N];
int n, k, mod;

void upd(int & var, int val) {
  var += val;
  if (var >= mod)
    var -= mod;
}

int main() {
  scanf("%d %d %d", &n, &k, &mod);
  dp[0][0] = 1;
  int sum = 0;
  for (int x = 1; x <= n; ++x) {
    memset(cnt, 0, sizeof cnt);
    sum += k * x;
    int full = k * x;
    for (int j = 0, z = 0; j <= sum; ++j) {
      int now = dp[x-1][j];
      upd(cnt[z], now);
      dp[x][j] = cnt[z];
      if (j >= full) {
        upd(cnt[z], mod - dp[x-1][j-full]);
      }
      ++z;
      if (z >= x)
        z -= x;
    }
  }
  for (int i = 1; i <= n; ++i) {
    int lef = i - 1, rig = n - i;
    long long ans = 0;
    for (int j = 0; j <= sum; ++j) {
      ans = (ans + 1LL * dp[lef][j] * dp[rig][j]) % mod;
    }
    ans = (ans * (k+1) - 1) % mod;
    if (ans < 0)
      ans += mod;
    printf("%lld\n", ans);
  }
  return 0;
}


#include <cstdio>
const int maxn=100+10;
struct E{
	int to;
	int next;
}ed[maxn*maxn*2];
int head[maxn];
int tot;
void J(int a,int b){
	ed[++tot].to=b;
	ed[tot].next=head[a];
	head[a]=tot;
}
int en;
int vis[maxn];
int ans;
void Dfs(int x){
	if(x==en+1){
		ans++;
		return;
	}
	if(!head[x]){
		Dfs(x+1);
		return;
	}
	for(int i=head[x];i;i=ed[i].next){
		if(vis[ed[i].to]){
			Dfs(x+1);
			return;
		}
	}
	Dfs(x+1);
	vis[x]=1;
	Dfs(x+1);
	vis[x]=0;
}
long long gcd(long long a,long long b){
	return b?gcd(b,a%b):a;
}
int main(){
	long long a,b;
	scanf("%lld%lld",&a,&b);
	en=b-a+1;
	for(int i=1;i<=b-a+1;i++)
		for(int j=1;j<=b-a+1;j++){
			if(i==j)
				continue;
			if(gcd(a+i-1,a+j-1)!=1){
				J(i,j);
				J(j,i);
			}
		}
	Dfs(1);
	int ha=0;
	for(int i=1;i<=b-a+1;i++)
		if(!head[i])
			ha++;
	printf("%lld",1ll*ans*(1ll<<ha));
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long
int const MAXN = 1 << 21;
int n, m, T;
int p[30], cnt;
int dp[MAXN];
void init() {
    for (int i = 2; i < 72; i++) {
        int f = 1;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) {
                f = 0;
                break;
            }
        }
        if (f) p[cnt++] = i;
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    init();
    dp[0] = 1;
    for (int x = A; x <= B; x++) {
        int bit = 0;
        for (int i = 0; i < cnt; i++)
            if (x % p[i] == 0) bit |= (1 << i);
        for (int i = 0; i < (1 << cnt); i++)
            if (!(bit & i)) {
                dp[bit | i] += dp[i];
            }
    }
    int ans = 0;
    for (int i = 0; i < (1 << cnt); i++) ans += dp[i];
    cout << ans;
    return 0;
}


# include <bits/stdc++.h>
# ifndef ngng628_library
# define ngng628_library
# define int long long
# define float long double
# define fi first
# define se second
# define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i,n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i,n) for(int i=((int)(n)); i>0; --i)
# define repr(i,b,e) for(int i=(b), i##_len=(e); i<i##_len; ++i)
# define reprs(i,b,e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define all(x) std::begin(x), std::end(x)
# define rall(x) std::rbegin(x), std::rend(x)
# define pb push_back
# define eb emplace_back
# define len(x) ((int)(x).size())
using namespace std;
template<class T> using vec = vector<T>;
using pii = pair<int, int>;
using vi = vec<int>;
using vvi = vec<vi>;
using db = deque<bool>;
using ddb = deque<db>;
using vs = vec<string>;
constexpr int INF = (1LL<<62)-(1LL<<31);
constexpr float EPS = 1e-10;
template<class T> istream& operator>>(istream& is, vec<T>& v) { for (auto& x : v) is >> x; return is; }
template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.fi >> p.se; }
template<class T> string join(const vec<T> &v){ stringstream s; rep (i, len(v)) s<<' '<<v[i]; return s.str().substr(1); }
template<class T> ostream& operator<<(ostream& os, const vec<T>& v){ if (len(v)) os << join(v); return os; }
template<class T> ostream& operator<<(ostream& os, const vec<vec<T>>& v){ rep (i, len(v)) if (len(v[i])) os << join(v[i]) << (i-len(v)+1 ? "\n" : ""); return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << p.fi << " " << p.se; }
template<class T, class U, class V> ostream& operator<<(ostream& os, const tuple<T, U, V>& t){ return os << get<0>(t) << " " << get<1>(t) << " " << get<2>(t); }
void print(){ cout << "\n"; }
template<class T, class... A>void print(const T& v, const A&...args){ cout << v; if(sizeof...(args))cout << " "; print(args...); }
void eprint() { cerr << "\n"; }
template<class T, class... A>void eprint(const T& v, const A&...args){ cerr << v; if(sizeof...(args))cerr << " "; eprint(args...); }
void drop(){ cout << "\n"; exit(0); }
template<class T, class... A>void drop(const T& v, const A&...args){ cout << v; if(sizeof...(args))cout << " "; drop(args...); }
template<class T> constexpr bool chmax(T &a, const T& b) { return a < b && (a = b, true); }
template<class T> constexpr bool chmin(T &a, const T& b) { return a > b && (a = b, true); }
constexpr int ctoi(const char c) { return ('0' <= c and c <= '9') ? (c - '0') : -1; }
struct Setup_io { Setup_io() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cerr.tie(0); cout << fixed << setprecision(15); } } setup_io;
# endif  // ngng628_library

vi divisor(int n) {
   vi v;
   for (int i = 1; i*i <= n; i++) {
       if (n % i == 0) {
           v.pb(i);
           if (i*i != n) v.pb(n / i);
       }
   }
   sort(all(v));
   return v;
}

struct Solver {
   void solve() {
      int n;
      cin >> n;

      if (n % 2 == 0 and (n / 2) & 1) {
         print("Same");
      }
      else if (n % 2 == 0) {
         print("Even");
      }
      else {
         print("Odd");
      }
   }
};

int32_t main() {
   int t;
   cin >> t;
   while (t--) {
      Solver solver;
      solver.solve();
   }
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
typedef long long ll;

using namespace std;
ll n;
void solve()
{
    cin >> n;
    int cnt = 0;
    while(n%2==0)
    {
        n/=2;
        cnt++;

    }
    if(cnt==1) cout << "Same" << endl;
    else if(cnt==0) cout << "Odd" << endl;
    else cout << "Even" << endl;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int tc=1;
	cin>>tc;
	for(int i=1;i<=tc;i++)
	{
		solve();
	}
 	return 0;
}

#include <bits/stdc++.h>
using namespace std;
long long n, t;
int main()
{
  ios_base::sync_with_stdio(false);
  cin>>t;
  while (t--)
  {
    cin>>n;
    if (n%2==1) cout<<"Odd"<<"\n";
    else if ((n/2)%2==1) cout<<"Same"<<"\n";
    else cout<<"Even"<<"\n";
  }
}


#include<iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <cstring>
#include <cassert>

using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

//#define L_JUDGE

#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar();  }
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    return x * f;

}

LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }

const int MOD=1e9+7;
const int MAXN=2010;

char G[MAXN][MAXN];
LL H, W;
LL d[MAXN][MAXN];

void Solve(){
    cin>>H>>W;
    int cnt=0;
    for(int i=0;i<H;i++){
        cin>>G[i];
        for(int j=0;j<W;j++){
            if(G[i][j]=='.')cnt++;
        }
    }
    memset(d, 0, sizeof(d));
    for(int ri=0;ri<H;ri++){
        int l[MAXN], r[MAXN];
        int a=-1, b=W;
        for(int ci=0;ci<W;ci++){
            if(G[ri][ci]=='#'){
                a=ci;
            }
            l[ci]=a;
        }
        for(int ci=W-1;ci>=0;ci--){
            if(G[ri][ci]=='#'){
                b=ci;
            }
            r[ci]=b;
        }
        for(int ci=0;ci<W;ci++){
            if(r[ci]-1>=l[ci]+1)
                d[ri][ci]+=(r[ci]-1-l[ci]-1);
        }
    }
    for(int ci=0;ci<W;ci++){
        int l[MAXN], r[MAXN];
        int a=-1,b=H;
        for(int ri=0;ri<H;ri++){
            if(G[ri][ci]=='#'){
                a=ri;
            }
            l[ri]=a;
        }
        for(int ri=H-1;ri>=0;ri--){
            if(G[ri][ci]=='#'){
                b=ri;
            }
            r[ri]=b;
        }
        for(int ri=0;ri<H;ri++){
            if(r[ri]-1>=l[ri]+1)
                d[ri][ci]+=(r[ri]-1-l[ri]);
        }
    }
    LL ans=0;
    for(int ri=0;ri<H;ri++){
        for(int ci=0;ci<W;ci++){
            if(G[ri][ci]=='#')continue;
            ans = ans+bin(2, cnt-d[ri][ci], MOD)*(bin(2, d[ri][ci], MOD)-1)%MOD;
            ans %= MOD;
        }
    }
    cout<<ans<<endl;
}

int main(){
#ifdef L_JUDGE
    freopen("in.txt","r",stdin);
    //		freopen("out.txt","w",stdout);
#endif
    Solve();
    return 0;

#ifdef L_JUDGE
    fclose(stdin);
    fclose(stdout);
    //		system("out.txt");
#endif

	return 0;
}

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<vector>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
using i64 = int_fast64_t;
constexpr i64 MAX = 10000000;
constexpr i64 MOD = 1000000007;
i64 fac[MAX], finv[MAX], inv[MAX];
template <i64 modulus>
class modcal
{

public:
  i64 a;

  constexpr modcal(const i64 x = 0) noexcept : a(x % modulus) {}
  constexpr i64 &value() noexcept { return a; }
  constexpr const i64 &value() const noexcept { return a; }
  constexpr modcal operator+(const modcal rhs) const noexcept
  {
    return modcal(*this) += rhs;
  }
  constexpr modcal operator-(const modcal rhs) const noexcept
  {
    return modcal(*this) -= rhs;
  }
  constexpr modcal operator*(const modcal rhs) const noexcept
  {
    return modcal(*this) *= rhs;
  }
  constexpr modcal operator/(const modcal rhs) noexcept
  {
    return modcal(*this) /= rhs;
  }
  constexpr modcal &operator+=(const modcal rhs) noexcept
  {
    a += rhs.a;
    if (a >= modulus)
    {
      a -= modulus;
    }
    return *this;
  }
  constexpr modcal &operator-=(const modcal rhs) noexcept
  {
    if (a < rhs.a)
    {
      a += modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modcal &operator*=(const modcal rhs) noexcept
  {
    a = a * rhs.a % modulus;
    return *this;
  }
  constexpr modcal &operator/=(modcal rhs) noexcept
  {
    i64 exp = modulus - 2;
    while (exp)
    {
      if (exp % 2)
      {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  void COMninit()
  {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
      fac[i] = fac[i - 1] * i % modulus;
      inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
      finv[i] = finv[i - 1] * inv[i] % modulus;
    }
  }
  i64 COMn(i64 n, i64 k)
  {
    if (n < k)
      return 0;
    if (n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
  }
  constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n)
  {
    if (n == 0)
      return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1)
      t = t * a;
    return t;
  }
};
using modc = modcal<1000000007>;
i64 Left[2100][2100],Right[2100][2100],Up[2100][2100],Down[2100][2100];
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 h,w;
    cin >> h >> w;
    vector<string> a(h);
    i64 k = 0;
    rep(i,h){
        cin >> a[i];
        rep(j,w){
            if(a[i][j] == '.')k++;
        }
    }
    rep(i,h){
        i64 cur = 0;
        rep(j,w){
            if(a[i][j] == '#')cur = 0;
            else cur++;
            Left[i][j] = cur;
        }
    }
    rep(i,h){
        i64 cur = 0;
        for(i32 j = w - 1; 0 <= j; j--){
            if(a[i][j] == '#')cur = 0;
            else cur++;
            Right[i][j] = cur;

        }
    }
    rep(j,w){
        i64 cur = 0;
        rep(i,h){
            if(a[i][j] == '#')cur = 0;
            else cur++;
            Up[i][j] = cur;
        }
    }
    rep(j,w) {
        i64 cur = 0;
        for (i32 i = h - 1; i >= 0; i--) {
            if (a[i][j] == '#')cur = 0;
            else cur++;
            Down[i][j] = cur;
        }
    }

    modc ans = 0;
    rep(i,h){
        rep(j,w){
            if(a[i][j] == '#')continue;
            i64 num = Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3;
            modc base = 2;
            ans += ans.modpow(base,k).a;
            ans -= ans.modpow(base,(k - num)).a;
        }
    }
    cout << ans.a << endl;
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

template <typename Abelian>
struct BIT {
  BIT(int n, const Abelian ID = 0) : n(n), ID(ID), dat(n, ID) {}

  void add(int idx, Abelian val) {
    while (idx < n) {
      dat[idx] += val;
      idx |= idx + 1;
    }
  }

  Abelian sum(int idx) const {
    Abelian res = ID;
    --idx;
    while (idx >= 0) {
      res += dat[idx];
      idx = (idx & (idx + 1)) - 1;
    }
    return res;
  }

  Abelian sum(int left, int right) const {
    return left < right ? sum(right) - sum(left) : ID;
  }

  Abelian operator[](const int idx) const { return sum(idx, idx + 1); }

  int lower_bound(Abelian val) const {
    if (val <= ID) return 0;
    int res = 0, exponent = 1;
    while (exponent <= n) exponent <<= 1;
    for (int mask = exponent >> 1; mask > 0; mask >>= 1) {
      if (res + mask - 1 < n && dat[res + mask - 1] < val) {
        val -= dat[res + mask - 1];
        res += mask;
      }
    }
    return res;
  }

private:
  int n;
  const Abelian ID;
  std::vector<Abelian> dat;
};

int main() {
  int n, m, q; cin >> n >> m >> q;
  vector<int> t(q), x(q), y(q); REP(i, q) cin >> t[i] >> x[i] >> y[i], --t[i], --x[i];
  vector<int> z = y;
  z.emplace_back(0);
  sort(ALL(z));
  z.erase(unique(ALL(z)), z.end());
  int l = z.size();
  vector<int> a[2]{vector<int>(n, 0), vector<int>(m, 0)};
  BIT<int> num[2]{BIT<int>(l), BIT<int>(l)};
  num[0].add(0, n);
  num[1].add(0, m);
  BIT<ll> sum[2]{BIT<ll>(l), BIT<ll>(l)};
  ll ans = 0;
  REP(i, q) {
    int c = t[i], d = t[i] ^ 1, idx = lower_bound(ALL(z), a[c][x[i]]) - z.begin();
    ans -= 1LL * num[d].sum(0, idx) * a[c][x[i]];
    ans -= sum[d].sum(idx, l);
    num[c].add(idx, -1);
    sum[c].add(idx, -a[c][x[i]]);
    idx = lower_bound(ALL(z), y[i]) - z.begin();
    ans += 1LL * num[d].sum(0, idx) * y[i];
    ans += sum[d].sum(idx, l);
    num[c].add(idx, 1);
    sum[c].add(idx, y[i]);
    a[c][x[i]] = y[i];
    cout << ans << '\n';
  }
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef unsigned long long ull;

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define ep emplace_back
#define EL printf("\n")
#define sz(A) (int) A.size()
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define FOD(i,r,l) for (int i=r;i>=l;i--)
#define fillchar(a,x) memset(a, x, sizeof (a))
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);

double MIN = 0;
int main()
{
    faster;
    int n;
    double D, H;
    cin >> n >> D >> H;
    FOR(i,1,n) {
        int d, h;
        cin >> d >> h;
        double d1 = D - d, h1 = H - h;
        double l = (h1 / d1) * D;
        MIN = max(MIN, H - l);
    }
    cout << MIN;
    return 0;
}


#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int64_t read_int() {
    int64_t ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    ungetc(ch, stdin);
    return sgn * ret;
}

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

template <typename T> inline void assign_min(T& x, const T& value) noexcept { x = min(x, value); }
template <typename T> inline void assign_max(T& x, const T& value) noexcept { x = max(x, value); }

constexpr char LF = '\n';

//-------------------------------------------------------------------------------------------------

int main() {
    vector<int64_t> A(4);
    REP(i, 4) { A[i] = read_int(); }
    int all_sum = A[0]+A[1]+A[2]+A[3];

    bool ok = false;
    REP(a, 2) REP(b, 2) REP(c, 2) REP(d, 2) {
        if (a+b+c+d > 0) {
            int64_t sum = 0;
            if(a > 0) sum += A[0];
            if(b > 0) sum += A[1];
            if(c > 0) sum += A[2];
            if(d > 0) sum += A[3];
            if(sum == all_sum-sum) {
                ok = true;
            }
        }
    }
    if (ok) cout << "Yes\n";
    else cout << "No\n";
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 25;
int G[MAXN][MAXN];
int n, m;
int dp[(1 << 18) + 10];
int solve(int x) {
    if (dp[x]) return dp[x];
    bool flag = 1;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (((x >> i) & 1) && ((x >> j) & 1)) {
                if (!G[i + 1][j + 1]) {
                    flag = 0;
                    break;
                }
            }
        }
    }
    if (flag) {
        return dp[x] = 1;
    }
    int res = MAXN;
    for (int s = x; s > 0; s = (s - 1) & x) {
        if (s == 0) break;
        if (s == x) continue;

        res = min(res, solve(s) + solve(x ^ s));
    }
    return dp[x] = res;
}
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u][v] = G[v][u] = 1;
    }
//    if (m == 0) {
//        printf("%d\n", n);
//        return 0;
//    }
    int ans = solve((1 << n) - 1);
    printf("%d\n", ans);
    return 0;
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,s,n) for(int i = s; i < (int)(n); i++)
#define Rep(i,s,n) for(int i = n; i >= (int)(s); i--)

int main() {
	int n;
	double d, h;
	cin >> n >> d >> h;
	double mk = h / d;
	rep(i, 0, n) {
		double a, b;
		cin >> a >> b;
		mk = min(mk, (h-b)/(d-a));
	}
	cout << fixed << setprecision(6) << h-mk*d << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=150;

int n,D,H,x[N],y[N];

bool ok(double mid){
    double slop=(double)(H-mid)/(double)(D-0);
    for(int i=0;i<n;i++){
        double val=slop*x[i]+mid;
        if(val<y[i])return false;
    }
    return true;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>D>>H;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    double l=0,r=H,ans;
    for(int rep=0;rep<100;rep++){
        double mid=(l+r)/2;
        //cout<<mid<<endl;
        if(ok(mid)){
            ans=mid;
            r=mid;
        }
        else {
            l=mid;
        }
    }
    cout<<fixed<<setprecision(17)<<ans<<'\n';

}


    #include <bits/stdc++.h>
    #define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    typedef unsigned long long      ll;
    #define rep(i,n)     for(int i=0;i<n;i++)
    #define gcd(a,b)       __gcd(a,b)
    #define lcm(a,b)	(a*b)/gcd(a,b)
    #define mem1(a)        memset(a,-1,sizeof(a))
    #define mem0(a)        memset(a,0,sizeof(a))
    #define vint        vector<int>
    #define pb            push_back
    #define pf            push_front
    #define ppb         pop_back
    #define all(v)      v.begin(),v.end()
    #define pii         pair<int,int>
    #define pic         pair<int,char>
    #define fr            first
    #define sc         second
    #define mp         make_pair
    #define inarr(a,n)	for(ll i=0;i<n;i++)cin>>a[i];
    #define showarr(a,x,y)	 for(ll i=x;i<y;i++)cout<<a[i]<<" ";
    #define PI   		3.1415926535897
    #define time_passed	1.0 * clock() / CLOCKS_PER_SEC
    using namespace std;

    double power(double a,int b) {if(b==0){return 1;}else if(b%2==0){return power(a*a,b/2);}else if(b%2==1){return a*power(a*a,(b-1)/2);}}
    bool cmp(pair<int,int>a,pair<int ,int> b){return a.second>b.second;}
    template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
    template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
    template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
    template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

    /*double f(double x,double Nu,double k){return power(x,k)-Nu;}
    double fd(double x,double Nu,double k){return k*pow(x,k-1);}
    double root(int Nu,int k){double ans=9;for(int i=1;i<20;i++){ans=ans-f(ans,Nu,k)/fd(ans,Nu,k);cout<<ans<<" ";}return ans;}
    */

    const ll mod=1e9+7;
    //const int inf=3e5+5;
    //const ll inf=1e9+7;
    int dy[]={-1,0,1,0};
    int dx[]={0,1,0,-1};
    //vector <int >adj[0];
    bool isprime(int n)
    {
        if(n==1)return false;
        if(n==2) return true;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)return false;
        }
        return true;

    }

    void love_for_infinity()
    {

        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<min(min(a,b),min(c,d));

    }

    int main()
    {    IOS
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        #ifdef SIEVE
        sieve();
        #endif
        #ifdef NCR
        init();
        #endif
        ll t;t=1;//cin>>t;
        while(t--){love_for_infinity();cout<<endl;}
        return 0;
    }

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mkp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<int>
#define mii             map<lli,lli>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define endl            "\n"
const double PI = acos(-1);

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
  return (a >= b ? a : b);
}

lli minm(lli a, lli b)
{
  return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
  lli res = 1;

  x = x % p;
  if (x == 0)
    return 0;

  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

#define FMAX 1000010
vector<lli> fact(FMAX, 1);
vector<lli> fact_inv(FMAX, 1);

lli nCrmodp(lli n, lli r, lli p)
{
  if (r > n)
    return 0;

  lli pro = (fact[n] * fact_inv[r]) % p;
  pro = (pro * fact_inv[n - r]) % mod;
  return pro;
}
void precompute()
{
  lli x = 1;
  for (lli i = 1; i < FMAX; ++i)
  {
    x *= i;
    x %= mod;
    fact[i] = x;
    fact_inv[i] = power(x, mod - 2, mod);
  }
}

void c_p_c()
{
  precompute();
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int main()
{
  c_p_c();

  vector<int>v(4);
  int ans= 1e9;
  for (int i = 0; i < 4; ++i)
  {
    cin >> v[i];
    ans = min(ans, v[i]);
  }
  cout << ans << endl;
  return 0;
}


#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> L_L;
const ll INF=2e18;
const ll MOD=1e9+7;
const double EPS=1e-9;

ll M,H;
int main(){
    cin>>M>>H;
    if(H%M==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
  [[nodiscard]]
#endif  // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
FixPoint final : private F
{
public:
  template <typename G>
  explicit constexpr FixPoint(G&& g) noexcept
    : F{std::forward<G>(g)}
  {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  noexcept(noexcept(F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif  // !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};  // class FixPoint

#if defined(__cpp_deduction_guides)
template <typename F>
FixPoint(F&&)
  -> FixPoint<std::decay_t<F>>;
#endif  // defined(__cpp_deduction_guides)

namespace
{
  template <typename F>
#if !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  #  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__((warn_unused_result))
#  elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_Check_return_)
_Check_return_
#  endif  // defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#endif  // !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  inline constexpr decltype(auto)
  makeFixPoint(F&& f) noexcept
  {
    return FixPoint<std::decay_t<F>>{std::forward<std::decay_t<F>>(f)};
  }
}  // namespace

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 M, H;
	cin >> M >> H;
	if ( H % M == 0) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

#define rmin(a,b) a = min<ll>(a,b)
#define rmax(a,b) a = max<ll>(a,b)

#define fi first
#define se second

const int N = 510;
ll dist[2][N][N];
int vis[2][N][N];
int n, m;

ll math[N][N], matv[N][N];

template <class T>
using pqt = priority_queue<T,vector<T>,greater<T>>;

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	fr(i,n) fr(j,m-1) cin >> math[i][j];
	fr(i,n-1) fr(j,m) cin >> matv[i][j];
	pqt<tuple<ll,bool,int,int>> pq;
	fr(cor,2) fr(i,n) fr(j,m) dist[cor][i][j] = LLONG_MAX;
	pq.emplace(0,0,0,0);
	dist[0][0][0] = 0;
	while(!pq.empty()){
		ll dac; bool cor; int i, j; tie(dac,cor,i,j) = pq.top(); pq.pop();
		if(vis[cor][i][j]) continue;
		vis[cor][i][j] = 1;
		dist[cor][i][j] = dac;
		if(j+1<m){
			pq.emplace(dac+math[i][j],0,i,j+1);
		}
		if(j-1>=0){
			pq.emplace(dac+math[i][j-1],0,i,j-1);
		}
		if(i+1<n){
			pq.emplace(dac+matv[i][j],0,i+1,j);
		}
		if(i-1>=0){
			if(cor==0){
				pq.emplace(dac+2,1,i-1,j);
			} else{
				pq.emplace(dac+1,1,i-1,j);
			}
		}
	}
	cout << dist[0][n-1][m-1] << "\n";

}

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll n, t;
    cin >> n >> t;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> pre, post;
    rep(i, n){
        if(i < (n+1)/2) pre.push_back(a[i]);
        else post.push_back(a[i]);
    }

    // for(auto e: pre) cout << e << " ";
    // cout << endl;
    // for(auto e: post) cout << e << " ";
    // cout << endl;

    unordered_set<ll> sm1;
    vector<ll> sm2;
    int n1 = pre.size();
    int n2 = post.size();

    rep(i, 1<<n1){
        vector<int> use(n1, 0);
        rep(j, n1){
            if(i & (1<<j)){
                use[j] = 1;
            }
        }

        ll sm = 0;
        rep(j, n1){
            if(use[j]) sm += pre[j];
        }

        sm1.insert(sm);
    }

    rep(i, 1<<n2){
        vector<int> use(n2, 0);
        rep(j, n2){
            if(i & (1<<j)){
                use[j] = 1;
            }
        }

        ll sm = 0;
        rep(j, n2){
            if(use[j]) sm += post[j];
        }

        sm2.push_back(sm);
    }

    // for(auto e: sm1) cout << e << " ";
    // cout << endl;
    // for(auto e: sm2) cout << e << " ";
    // cout << endl;

    sort(sm2.begin(), sm2.end());

    ll res = 0;
    for(auto e: sm1){
        if(e > t) continue;

        int idx = lower_bound(sm2.begin(), sm2.end(), t-e) - sm2.begin();
        ll val = sm2[idx]+e;
        if(idx == 0) val = e;
        if(idx == (int)sm2.size()) val = sm2.back()+e;

        if(val > t){
            if(idx == 0) val = 0;
            else val = sm2[idx-1] + e;
        }

        res = max(res, val);
        // cout << e << " " << idx << " " << val << " " << res << endl;
    }

    cout << res << endl;

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
#define MOD 1000000007
#define PI 3.1415926535897932
#define INF 1e18
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repe(i, j, n) for (ll i = j; i < n; i++)
#define repi(i, n) for (ll i = 0; i <= n; i++)
#define repie(i, j, n) for (ll i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<ll, ll>
#define fi first
#define se second
using Graph = vector<vector<ll>>;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

ll dp[2000][2000];
ll nCr(ll n, ll r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n%MOD;
       if(dp[n][r]) return dp[n][r]%MOD;
       return dp[n][r] = nCr(n-1,r)%MOD + nCr(n-1,r-1)%MOD;
}

ll H(ll n, ll r) {
    return nCr(n+r-1, r)%MOD;
}

int prime[10000000];
bool is_prime[100000000 + 1];

int sieve(int n) {
    int pcnt = 0;
    for(int i = 0; i <= n; i++) {
        is_prime[i] = true;
    }

    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++) {
        if(is_prime[i]) {
            prime[pcnt++] = i;
            for(int j = 2*i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }

    return pcnt;
}

struct UnionFind {
	//自身が親であれば、その集合に属する頂点数に-1を掛けたもの
	//そうでなければ親のid
	vector<ll> r;
	UnionFind(ll N) {
		r = vector<ll>(N, -1);
	}
	ll root(ll x) {
		if (r[x] < 0) return x;
		return r[x] = root(r[x]);
	}
	bool unite(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (r[x] > r[y]) swap(x, y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}
	ll size(ll x) {
		return -r[root(x)];
	}

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

void solve1() {
    ll n, q; string s; cin >> n >> s >> q;
    string pre, post;
    pre = s.substr(0, n);
    post = s.substr(n, n);
    bool f = true;
    //cout << pre << " " << post << endl;
    rep(i, q) {
        int t, a, b; cin >> t >> a >> b;
        if(t == 1) {

                if(a <= n && b <= n) {
                    swap(pre[a-1], pre[b-1]);
                } else if(a <= n && b > n) {
                    swap(pre[a-1], post[b-1-n]);
                } else {
                    swap(post[a-1-n], post[b-1-n]);
                }
        } else {
            swap(post, pre);

        }
    }

  cout << pre + post << endl;
}

int main()
{
    solve1();
}

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
//Arr.find_by_order(k-1):kth smallest
//Arr.order_of_key(X):no. of elements less than x
#define int long long
#define ld long double
#define dob double
#define pb push_back
#define tle ios_base::sync_with_stdio(false);cin.tie(NULL);
const int hell=1e9+7;
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int>>
int inf=1e18;
const int N=1e5+9;
//getline(cin,st);   To Take Entire Sentence In Input;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool prime(int n)
{
        for( int i=2;i*i<=n;i++)
        {
                if(n%i==0)
                return false;
        }
        return true;
}

int power(int a,int b,int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int32_t main()
{
	tle
	int t=1;
	// cin>>t;
	//precompute();

	while(t--)
	{

		int n;
		cin>>n;

		string s;
		cin>>s;

		int q;
		cin>>q;

		int ct=0;

		for(int i=0;i<q;i++)
		{
			int typ,l,r;
			cin>>typ>>l>>r;

			if(typ==1)
			{
				if(ct%2==0)
				swap(s[l-1],s[r-1]);
				else
				{
					if(l<=n)
					l=l+n;
					else
					l=l-n;

					if(r<=n)
					r=r+n;
					else
					r=r-n;

					swap(s[l-1],s[r-1]);
				}
			}
			else
			ct++;
		}

		// reverse(s.begin(),s.end());
		if(ct%2==1)
		s=s.substr(n)+s.substr(0,n);
		cout<<s;

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const ll siz = 3e5 + 7;
ll t[4 * siz];
int n, q;
void built(int a[], int tl , int tr, int v) {
	if (tl == tr) {
		t[v] = a[tl];
	}
	else
	{
		int tm = (tl + tr) / 2;
		built(a, tl, tm, 2 * v);
		built(a, tm + 1, tr, 2 * v + 1);
		t[v] = (t[2 * v] ^ t[2 * v + 1]);
	}
}

void update(int v, int tl, int tr, int pos, int val) {
	if (tl == tr) {
		t[v] = val;
	}
	else
	{
		int tm = (tl + tr) / 2;
		if (pos <= tm)
			update(2 * v, tl, tm, pos, val);
		else
			update(2 * v + 1, tm + 1, tr, pos, val);
		t[v] = (t[2 * v] ^ t[2 * v + 1]);
	}
}

ll query(int v, int tl, int tr , int l , int r) {
	if (l > r)return 0;
	if (l == tl && r == tr) {
		return t[v];
	}
	int tm = (tr + tl) / 2;
	return (query(2 * v, tl, tm, l, min(r, tm)) ^query(2 * v + 1, tm + 1, tr, max(l, tm + 1), r));
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> q;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	built(a, 0, n - 1, 1);
	while (q--) {
		int t;
		cin >> t;
		if (t == 2) {
			int u, v;
			cin >> u >> v;
			--u;
			--v;
			cout << query(1, 0, n - 1, u, v) << endl;
		}
		else
		{
			int u, v;
			cin >> u >> v;
			--u;
			int by = v ^ a[u];
			update(1, 0, n - 1, u, by);
			a[u] = by;
		}
	}
}

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main() {
#ifdef DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N, Q;
    cin >> N >> Q;
    static ll A[300300];
    static ll T[300300];
    static ll X[300300];
    static ll Y[300300];
    BinaryIndexedTree<ll>* Count[31];

    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < Q; i++){
        cin >> T[i] >> X[i] >> Y[i];
    }
    for(int j = 0; j < 31; j++){
        Count[j] = new BinaryIndexedTree<ll>(N*2);
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < 31; j++){
            if( (A[i] >> j) & 1){
                Count[j]->add(i, 1);
            }
        }
    }

    for(int i = 0; i < Q; i++){
        if(T[i] == 1){
            ll newA = A[X[i]] ^ Y[i];
            for(int j = 0; j < 31; j++){
                if( (A[X[i]] >> j) & 1){
                    Count[j]->add(X[i]-1, 1);
                }
                if( (newA >> j) & 1){
                    Count[j]->add(X[i]-1, 1);
                }
            }
            A[X[i]] = newA;
        }else{
            ll output = 0;
            ll two = 1;
            for(int j = 0; j < 31; j++){
                if(X[i] > 1){
                if( (Count[j]->sum(Y[i]-1) - Count[j]->sum(X[i]-2)) % 2 == 1){
                    output += two;
                }
                }else{
                    if( (Count[j]->sum(Y[i]-1)) % 2 == 1){
                        output += two;
                    }
                }
                two *= 2;
            }
            cout << output << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define gc() getchar()
using namespace std;
typedef long long ll;

template <typename T> void rd(T &x){
	ll f=1;x=0;char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	x*=f;
}

ll n,q,h[100010],ans;

inline void bsh(ll k){
	ll l=0,r=h[n]+k+1,mid,f;
	while(l+1<r){
		mid=l+r>>1;
		f=lower_bound(h+1,h+n+1,mid)-h-1;
		//printf("%lld %lld %lld %lld\n",l,r,mid,f);
		if(mid-f>k)r=mid;
		else l=mid;
	}
	printf("%lld\n",l);
}

int main(){
	rd(n),rd(q);
	for(ll i=1;i<=n;i++)rd(h[i]);
	for(ll i=1,t;i<=q;i++){
		rd(t);
		bsh(t);
	}
	return 0;
}

#include "bits/stdc++.h"
typedef long long int ll;
using namespace std;

int64_t  n, q;
void solve() {
    cin >> n >> q;
    vector<int64_t> a;
    for(int i=0;i<n;++i) {
        int64_t t;  cin >> t;
        a.push_back(t);
    }
    sort(a.begin(), a.end());
    for(int i=0;i<q;++i) {
        int64_t k; cin >> k;
        int64_t pre = 0;
        while(1) {
            int64_t cnt = upper_bound(a.begin(), a.end(), k) - upper_bound(a.begin(), a.end(), pre);
            if(cnt == 0)
                break;
            pre = k;
            k += cnt;
        }
        cout << k << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int T = 1;
    while(T--) solve();
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;

const int inf = 1e18;
const int max_n = 3010;
const int Mod = 998244353;

int n,k;
int dp[max_n][max_n];

int f(int n,int k){
	if(n>k) return 0;
	if(k==0){
		if(n==0) return 1;
		else return 0;
	}
	if(n==0){
		return 0;
	}
	if(dp[n][k]!=-1) return dp[n][k];

	int t1 = f(n-1,k-1);
	int t2 = f(2*n,k);
	int ans = (t1+t2)%Mod;
	dp[n][k]=ans;
	return ans;
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	swap(n,k);

	cout<<f(n,k)<<endl;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll a,b;
  cin >> a >> b;
  cout << (a+b)/2 << " " << (a-b)/2 << endl;

  return 0;

}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using matrix = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
void Cout(ll x) {cout << x << endl; exit(0);}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

matrix E = {{1,0,0},{0,1,0},{0,0,1}};

matrix op1 = {{0,1,0},{-1,0,0},{0,0,1}};
matrix op2 = {{0,-1,0},{1,0,0},{0,0,1}};
matrix op3 = {{-1,0,0},{0,1,0},{0,0,1}};
matrix op4 = {{1,0,0},{0,-1,0},{0,0,1}};

matrix pre3(ll p) {
    matrix res = op3;
    res[0][2] = 2*p;
    return res;
}

matrix pre4(ll p) {
    matrix res = op4;
    res[1][2] = 2*p;
    return res;
}

matrix times(matrix X, matrix Y) {
    ll H = X.size(), W = Y[0].size(), K = Y.size();
    matrix res(H,vector<ll>(W));
    rep(i,H) rep(j,W) {
        rep(k,K) res[i][j] += X[i][k]*Y[k][j];
    }
    return res;
}

int main() {
    ll N; cin >> N;
    vector<matrix> vec(N);
    rep(i,N) {
        ll x, y; cin >> x >> y;
        vec[i] = {{x},{y},{1}};
    }
    ll M; cin >> M;
    vector<matrix> op(M+1,E);
    repp(i,1,M+1) {
        ll com; cin >> com;
        if (com==1) op[i] = times(op1,op[i-1]);
        else if (com==2) op[i] = times(op2,op[i-1]);
        else {
            ll p; cin >> p;
            matrix opt;
            if (com==3) opt = pre3(p);
            else opt = pre4(p);
            op[i] = times(opt,op[i-1]);
        }
    }
    ll Q; cin >> Q;
    vector<ll> X(Q), Y(Q);
    rep(i,Q) {
        ll a, b; cin >> a >> b;
        b--;
        matrix tmp = times(op[a],vec[b]);
        X[i] = tmp[0][0];
        Y[i] = tmp[1][0];
    }
    rep(i,Q) cout << X[i] << " " << Y[i] << endl;
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 1600008
#define mod 998244353
#define f first
#define s second
ll arr[sz+10],brr[sz+10];
ll num=1;
char c[sz];
std::vector<ll> v[34];
long long binpow(long long a, long long b,long long mod1) {
    a %= mod1;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod1;
        a = a * a % mod1;
        b >>= 1;
    }
    return res;
}
int main()
{
  int t=1;
  //scanf("%d",&t);
  for(int cs=1;cs<=t;cs++)
  {
      ll a,b,c;
      scanf("%lld %lld %lld",&a,&b,&c);
      a%=10;
      ll n=a;
      arr[n]++;
      ll val=0;
      for(int i=2;;i++)
      {
       n=(n*a)%10;
       if(arr[n])
       {
        val=i-1;
        break;
       }
      }
      ll a1=binpow(b,c,val);
      if(a1==0)
      	a1=val;
      	n=a;
      	for(int i=2;i<=a1;i++)
      		n=(n*a)%10;
        a=n;
        printf("%lld\n",a);
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

pair<int, int> diam_dfs(int v, int p, int dep, const vector<vector<int>> &G, vector<pair<int, int>> &ds) {
  pair<int, int> res(dep, v);
  for (auto &u : G[v]) {
    if (u == p) continue;
    chmax(res, diam_dfs(u, v, dep + 1, G, ds));
  }

  ds[v] = res;
  return res;
}

void dfs(int v, int p, int &e, const vector<vector<int>> &G, const vector<pair<int, int>> &ds, vector< int > &ans) {
  ans[v] = e;

  vector< pair<int, int> > us;
  for (auto &u : G[v]) {
    if (u == p) continue;
    us.emplace_back(ds[u].first, u);
  }

  whole(sort, us);
  for (auto &[d, u] : us) {
    e++;
    dfs(u, v, e, G, ds, ans);
    e++;
  }
}

void solve() {
  int n = input();

  vector< vector< int > > G(n);
  range(i, 1, n) {
    int a = input() - 1, b = input() - 1;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector< pair<int, int> > ds(n);
  auto [d0, v0] = diam_dfs(0, -1, 0, G, ds);
  diam_dfs(v0, -1, 0, G, ds);

  int e = 1;
  vector< int > ans(n);
  dfs(v0, -1, e, G, ds, ans);

  cout << ans << endl;
}

signed main() {
  solve();
}

#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define endl "\n"

using namespace std;

const int max_n = 2e5+100;
const int off_set = 1e5+5;
const int max_A = 55;
const int Mod = 1e9+7;
const int inf = 2e18;

int n;
vector<int> adj[max_n];

int depth[max_n],dp[max_n];

void dfs(int v,int p,int d){
    depth[v]=d;
    dp[v]=d;

    for(int x:adj[v]) if(x!=p){
        dfs(x,v,d+1);
        dp[v]=max(dp[v],dp[x]+1);
    }

    return;
}

int ans[max_n];
int counter;

void solve(int v,int p){
    ans[v]=counter;

    for(int x:adj[v]) if(x!=p){
        counter++;
        solve(x,v);
        counter++;
    }

}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(int i=0;i<n-1;i++){
        int x,y;cin>>x>>y;x--;y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs(0,-1,0);

    int farthest=0;
    for(int i=0;i<n;i++) if(depth[i]>depth[farthest]){
        farthest=i;
    }

    dfs(farthest,-1,0);

    for(int i=0;i<n;i++){
        sort(adj[i].begin(),adj[i].end(),[](const int& a,const int& b)->bool{
            return dp[a]<dp[b];
        });
    }

    solve(farthest,-1);

    for(int i=0;i<n;i++){
        cout<<ans[i]+1<<" ";
    }
    cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define rep(i,n) for (ll i = 0;i<(n);++i)
#define all(v) v.begin(),v.end()

template <typename T>bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false;}
template <typename T>bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false;}
vector<long long> divisor(long long n){vector<long long> res;long long i = 1;while (i*i<=n){if(n%i==0){res.push_back(i);}i++;}if(res.size()==0)return res;for(long long i = res.size()-1-(res.back()*res.back()==n);i>=0;--i){res.push_back(n/res[i]);}return res;}
long long safe_mod(long long x,long long m){x%=m;if(x<0){x+=m;}return x;}
long long modpow(long long x,long long n,long long mod){long long ans=1;while(n>0){if(n&1){ans*=x;ans%=mod;}n>>=1;x*=x;x%=mod;}return ans;}
long long intpow(long long x,long long n){long long ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
//template<typename T>T intpow(T x,T n){T ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
vector<pair<long long,long long>> factor_lst(long long n){vector<pair<long long,long long>> factor_lst;long long d=2;while(d*d<=n){if(n%d==0){long long num=0;while(n%d==0){num+=1;n/=d;}factor_lst.push_back({d,num});}d+=1;}if(n!=1){factor_lst.push_back({n,1});}return factor_lst;}
#define Uniq(a) sort(all(a));a.erase(unique(all(a)),end(a))

int msb(int x){return x==0 ? -1:32-__builtin_clz(x);}//1-indexed
int lsb(int x){return x==0 ? 32:__builtin_ctz(x)+1;}//1-indexed
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(long long x){return __builtin_popcount(x);}

bool ingrid(int i,int j,int H,int W){
    return 0<=i&&i<H&&0<=j&&j<W;
}

const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
template<typename T> void print(vector<T> &v){for(int i=0;i<v.size();++i){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
template<typename T> void print(T* v,int size){for(int i=0;i<size;++i){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
template<typename T,typename S>void print(pair<T,S>&p){cout<<p.first<<" "<<p.second<<endl;}
const ll LINF=4*1e18;
const ll MINF=5*1e15;
const int INF=1e9+5;
const ld PI=acosl(-1);
const ld DINF=INF;

void Main();
int main(){cout<<fixed<<setprecision(15);Main();}

void Main(){

int N,M;cin>>N>>M;
vector<pair<int,int>> P(M);
vector<int> lstx,lsty;
lstx.push_back(0);
lsty.push_back(N);
lsty.push_back(N+1);
rep(i,M){
    cin>>P[i].first>>P[i].second;
    lstx.push_back(P[i].first);
    lsty.push_back(P[i].second);
    lsty.push_back(P[i].second+1);
}
Uniq(lstx);Uniq(lsty);
map<int,int> mx,my;
rep(i,lstx.size())mx[lstx[i]]=i;
rep(i,lsty.size())my[lsty[i]]=i;
vector<vector<int>> query(lstx.size());
rep(i,M)query[mx[P[i].first]].push_back(my[P[i].second]);
vector<bool> dp(lsty.size(),false);
dp[my[N]]=true;
rep(i,lstx.size()){
    vector<bool> lst(query[i].size());
    rep(j,query[i].size()){
        lst[j]=(query[i][j]>0&&dp[query[i][j]-1])||((query[i][j]<lsty.size()-1)&&dp[query[i][j]+1]);
    }
    rep(j,query[i].size()){
        dp[query[i][j]]=lst[j];
    }
}
int ans=0;
rep(i,lsty.size()-1)if(dp[i])ans+=lsty[i+1]-lsty[i];
cout<<ans<<endl;
}

/*
AtCoder Regular Contest 111 - A - Simple Math 2
https://atcoder.jp/contests/arc111/tasks/arc111_a
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
ll MOD = 1000000007;

// ll sum() { return 0; }
// template<typename T, typename... Args>
// T sum(T a, Args... args) { return a + sum(args...); }

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl

void solve() {
    // [10 ^ N / M] % M
    // = [10 ^ N - k * M ^ 2] % M
    // = [10 ^ N / M] % M
    ll n, m;
    cin >> n >> m;
    ll sq = m * m, ans = 1, pow = 10;
    while (n > 0) {
        if (n & 1) ans = (ans * pow) % sq;
        pow = (pow * pow) % sq;
        n >>= 1;
    }
    OUT((ans / m) % m);
}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif

    // int tc; cin >> tc;
    // TC(tc) solve();
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
/*
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
*/
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
ll mod_pow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

const int mod = 1e9 + 7;

int conv(string &S, string &T) {
    int ret = 0;
    int N = S.size();
    priority_queue<int, vector<int>, greater<int>> Q;
    for (int i = 0; i < N; i++) {
        if (T[i] == '0') {
            Q.push(i);
        }
    }
    for (int i = 0; i < N; i++) {
        if (T[i] == '1' && S[i] == '0') {
            while(!Q.empty()) {
                int x = Q.top(); Q.pop();
                if (x <= i) continue;
                swap(T[i], T[x]);
                ret++;
                break;
            }
        }
    }
    return ret;
}

int f(string &S, string &T) {
    string S_ = T, T_ = S;

    int r1 = conv(S, T);
    reverse(all(S));
    reverse(all(T));
    int r2 = conv(S, T);

    int r3 = conv(S_, T_);
    reverse(all(S_));
    reverse(all(T_));
    int r4 = conv(S_, T_);

    return min(r1 + r2, r3 + r4);
}

void solve() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    int s1 = 0, t1 = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '1') s1++;
    }
    for (int i = 0; i < N; i++) {
        if (T[i] == '1') t1++;
    }
    if (s1 != t1) {
        cout << "-1" << endl;
        return;
    }

    int prev = 0;
    s1 = 0, t1 = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '1') s1++;
        if (T[i] == '1') t1++;
        if (s1 == t1) {
            string s = S.substr(prev, i + 1 - prev);
            string t = T.substr(prev, i + 1 - prev);
            ans += f(s, t);
            prev = i + 1;
        }
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);

    solve();
}

#include <bits/stdc++.h>
using namespace std ;

int N, ans=0;
string S, T;
vector<int> a, b;

int main(){
  cin >> N >> S >> T;
  bool f=true;
  int x=-1;
  for(int i=0;i<N;i++){
    if(S[i]=='0')a.push_back(i);
    if(T[i]=='0')b.push_back(i);
  }
  if(a.size()!=b.size())puts("-1");
  else{
    for(int i=0;i<a.size();i++){
      if(a[i]!=b[i])ans++;
    }
    cout << ans << endl;
  }

  return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define Q 400005
using namespace std;
#define gc() getchar()
inline bool ig(char c){return c>='0'&&c<='9';}
inline void read(int &oi){char c;int f=1,rs=0;while(c=gc(),(!ig(c))&&c!='-');c^'-'?rs=(c^48):f=-1;while(c=gc(),ig(c))rs=rs*10+(c^48);oi=rs*f;}
inline void print(int oi){if(oi<0)putchar('-'),oi=~oi+1;if(oi>9)print(oi/10);putchar(oi%10+48);}
int n,q;char c[Q];bool flag;
int main(){
	read(n);scanf("%s",c);read(q);
	for(int i=1;i<=q;++i){
		int opt,x,y;read(opt);read(x);read(y);
		if(opt==2)flag^=1;
		else{
			if(flag){
				if(x>n)x-=n;else x+=n;
				if(y>n)y-=n;else y+=n;
			}
			char ch=c[x-1];
			c[x-1]=c[y-1];c[y-1]=ch;
		}
	}
	if(flag){
		for(int i=n;i<=2*n-1;++i)putchar(c[i]);
		for(int i=0;i<=n-1;++i)putchar(c[i]);putchar('\n');
	}
	else printf("%s\n",c);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}

void Main(){
    int N,M; cin >> N >> M;
    VI A(N); REP(i,N) cin >> A[i];
    VI B(M); REP(i,M) cin >> B[i];

    ll dp[N+1][M+1]; REP(i,N+1)REP(j,M+1) dp[i][j] = LINF;
    dp[0][0] = 0;
    REP(i,N) dp[i+1][0] = i+1;
    REP(i,M) dp[0][i+1] = i+1;

    ll cummin[N+1][M+1]; REP(i,N+1)REP(j,M+1) cummin[i][j] = LINF;
    cummin[0][0] = 0;
    REP(i,N) cummin[i+1][0] = i+1;
    REP(i,M) cummin[0][i+1] = i+1;

    REP(i,N)REP(j,M){
        // 取り除く場合
        chmin(dp[i+1][j+1], dp[i][j]+2);
        chmin(dp[i+1][j+1], dp[i][j+1]+1);
        chmin(dp[i+1][j+1], dp[i+1][j]+1);

        // 残す場合
        if(A[i]==B[j]) chmin(dp[i+1][j+1], dp[i][j]);
        else chmin(dp[i+1][j+1], dp[i][j]+1);
    }
    ll ans = dp[N][M];
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    ll ans=0,mx=0,s=0,k=0;
    for(int i=1;i<=n;i++){
        ll x;cin>>x;
        s+=x;
        k=max(k,s);
        ans+=k;
        mx=max(ans,mx);
        ans+=s-k;
        // cout<<ans<<" "<<s<<'\n';
    }
    cout<<mx<<'\n';
    return 0;
}

#include<bits/stdc++.h>

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    long long n;
    cin>>n;

    long long a[n];
    rep(i,n){
        cin>>a[i];
    }
    long long s[n+1];
    s[0]=0;
    long long M[n+1];//M[i]:=i番目までの累積和の最大
    M[0]=0;
    rep(i,n){
        s[i+1]=s[i]+a[i];
        if(s[i+1]>M[i]){
            M[i+1]=s[i+1];
        }
        else{
            M[i+1]=M[i];
        }
    }
    long long ans=0;
    long long now=0;
    rep2(i,n){
        ans=max(now+M[i],ans);
        now+=s[i];
        //ans=max(now,ans);

        //cout<<ans<<endl;
    }
    cout<<ans<<endl;

}
/*

*/


//help others........
#include <iostream>
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define lli long long int
#define pb push_back
#define F first
#define S second
#define pii pair<long long,int>
#define all(a) a.begin(),a.end()
#define read(n,a) for(int i = 0;i<n;i++){cin>>a[i];}

ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll mod = 1e9+7;

ll fct[1009];

int N = 509;

void fact() {
	fct[0] = 1;
	fct[1] = 1;
	for (ll i = 2; i <= 1000; i++)
		fct[i] = (i * fct[i-1])%mod;
}

bool find(int s,vector<int>a){

	for(int i = 0;i<(int)a.size();i++)
	{
		if(a[i] == s)
			return true;
	}
	return false;

}
void getans()
{
	int a,b;
	cin>>a>>b;
	int c = a+b;

	if(c>=15 && b >=8)
		cout<<1<<endl;
	else if(c>=10&& b>=3)
		cout<<2<<endl;
	else if(c>=3)
		cout<<3<<endl;
	else
		cout<<4<<endl;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	//cin>>t;
	while(t--)
		getans();
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  if(a+b>=15&&b>=8){
    cout<<"1\n";
  }else if(a+b>=10&&b>=3){
    cout<<"2\n";
  }else if(a+b>=3){
    cout<<"3\n";
  }else{
    cout<<"4\n";
  }
}


//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000007
#define MAXR 100000 //10^5:配列の最大のrange

//最大化問題最小化問題
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N;
    cin >> N;

    FOR(i,1,log(N)){
        FOR(j,1,log(N)){
        if(N==powl(5,i)+powl(3,j)){cout << j << " " << i << endl;
        return 0;
        }
        }
    }

    //出力
    cout << -1 << endl;
    //cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<climits>
#include<complex>
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define int long long
template<typename T>
void dbg_a(T *a,int l,int r){cout<<" {";for(int i = l;i<r;i++) cout<<a[i]<<", ";cout<<a[r]<<"}"<<endl;}
typedef long long ll;
template<typename T = int>
inline T read(){
    T f = 1,r = 0;
    char c = getchar();
    while(c<'0'||c>'9'){if(c == '-') f = -1; c = getchar();}
    while(c>='0'&&c<='9'){ r = (r<<1) + (r<<3) + c - '0';c = getchar();}
    return f*r;
}
typedef pair<int,int> PII;
#define fi first
#define se second
#define mst(a,b) memset(a,b,sizeof(a))
#define For(i,a,b) for(int i = a;i<=b;i++)
#define For_(i,a,b) for(int i = a;i>=b;i--)
#define _for(i,a) for(int i = 0;i<a;i++)
#define All(x) x.begin(),x.end()

//    For(i,1,n) For(j,1,m) printf("f[%lld][%lld] = %lld\n",a,b,c);

const int N = 8 + 2,M = N*2 + 10,INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int n,k;

void solve(){
    n = read();
    int a = read(),b = read();
    int d = n - b - a;
    if(d < 0){
        cout<<0<<"\n";
        return ;
    }
    int ans1 = (d + 1) % mod * (d + 2) % mod * (n - a + 1) % mod * (n - b + 1) % mod;
    int ans2 = (d + 1) * (d + 1) % mod * (d + 2) %mod * (d + 2) % mod;
    cout<<(ans1 * 2 - ans2 + mod)%mod<<"\n";
}

signed main(){
    int T = 1;
    T = read();
    while(T--) solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define vt vector
#define all(x) x.begin(), x.end()
#define trav(i, x) for(auto &i : x)
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define top front
void solve() {
    int n, m; scanf("%d%d", &n, &m);
    vector<vector<char>> G(n, vector<char> (m));
    for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			cin >> G[i][j];
		}
	}
	int row_count = 0;
	for(int i = 0; i < n - 1; i++) {
		for(int j = 0; j < m - 1; j++) {
			int c=0;
			c += G[i][j]=='#';
			c += G[i+1][j]=='#';
			c += G[i][j+1]=='#';
			c += G[i+1][j+1]=='#';
			if(c==1||c==3) row_count++;
		}
	}

	printf("%d", row_count);

}
int main() {

	int t = 1, i = 1;
	while(t--) {
		// printf("Case #%d: ", i)
		solve();
		i++;
	}
}

#include <bits/stdc++.h>
using namespace std;

template <class A, class B> bool cmin(A& a, B b) { return a > b && (a = b, true); }
template <class A, class B> bool cmax(A& a, B b) { return a < b && (a = b, true); }

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  int N, X;
  cin >> N >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  for (const auto& a : A) {
    if (a == X) continue;
    cout << a << '\n';
  }
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) begin(v), end(v)
#define sz(v) v.size()
#define INF 1e18+9
#define EPSILON 1e-14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll si, sj;
vector<vector<ll>> p(50, vector<ll>(50));
vector<bool> vst(2500, false);
vector<vector<ll>> t(50, vector<ll>(50));

ll scoring(string S){
    ll score = 0;
    score += p.at(si).at(sj);
    vst.at(t.at(si).at(sj)) = true;
    ll px = si;
    ll py = sj;
    rep(i, sz(S)){
        if(S.at(i) == 'U'){
            px--;
        }
        else if(S.at(i) == 'D'){
            px++;
        }
        else if(S.at(i) == 'L'){
            py--;
        }
        else if(S.at(i) == 'R'){
            py++;
        }
        if(vst.at(t.at(px).at(py))){
            cerr << t.at(px).at(py) << ": twice visited" << endl;
            return -1;
        }
        else{
            vst.at(t.at(px).at(py)) = true;
            score += p.at(px).at(py);
        }
    }
    return score;
}

string solve(){
    string ans = "";
    vector<ll> dx = {-1, 1, 0, 0};
    vector<ll> dy = {0, 0, -1, 1};
    string dir = "UDLR";
    ll px = si;
    ll py = sj;
    vst.at(t.at(si).at(sj)) = true;
    while(true){
        bool move = false;
        rep(i, 4){
            if(0 <= px+dx.at(i) && px+dx.at(i) <= 49 && 0 <= py+dy.at(i) && py+dy.at(i) <= 49 && !vst.at(t.at(px+dx.at(i)).at(py+dy.at(i)))){
                px += dx.at(i);
                py += dy.at(i);
                vst.at(t.at(px).at(py)) = true;
                ans += dir.at(i);
                move = true;
                break;
            }
        }
        if(!move){
            break;
        }
    }
    return ans;
}

string greed(){
    string ans = "";
    vector<ll> dx = {-1, 1, 0, 0};
    vector<ll> dy = {0, 0, -1, 1};
    string dir = "UDLR";
    ll px = si;
    ll py = sj;
    vst.at(t.at(si).at(sj)) = true;
    while(true){
        ll add = 0;
        ll d = -1;
        rep(i, 4){
            if(0 <= px+dx.at(i) && px+dx.at(i) <= 49 && 0 <= py+dy.at(i) && py+dy.at(i) <= 49 && !vst.at(t.at(px+dx.at(i)).at(py+dy.at(i)))){
                if(chmax(add, p.at(px+dx.at(i)).at(py+dy.at(i)))){
                    d = i;
                }
            }
        }
        if(d == -1){
            break;
        }
        px += dx.at(d);
        py += dy.at(d);
        vst.at(t.at(px).at(py)) = true;
        ans += dir.at(d);
    }
    return ans;
}

int main()
{
    cin >> si >> sj;
    rep(i, 50){
        rep(j, 50){
            cin >> t.at(i).at(j);
        }
    }
    rep(i, 50){
        rep(j, 50){
            cin >> p.at(i).at(j);
        }
    }
    cout << greed() << endl;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int si, sj;
vector<vector<int>> t(50, vector<int>(50,0));
vector<vector<int>> p(50, vector<int>(50,0));
vector<vector<bool>> used(50, vector<bool>(50, false));
string ans_s;

int score() {
    int ans = 0;
    return ans;
}

void solve() {
    queue<P> q;
    q.push(make_pair(si, sj));
    used.at(si).at(sj) = true;

    for (int i = 0; i < 4; i++) {
        int xd = si + dx[i];
        int yd = sj + dy[i];
        if (xd >= 0 && xd < 50 && yd >= 0 && yd < 50 && t.at(si).at(sj) == t.at(xd).at(yd)) used.at(xd).at(yd) = true;
    }
    ll s = 0;

    mt19937 mt(1234);
    uniform_int_distribution<> rand4(0, 3);
    int cnt = 0, false_cnt = 0;

    while(!q.empty() && false_cnt < 10 && cnt < 100000000) {
        P tmp = q.front();

        int i = rand4(mt);
        int x = tmp.first + dx[i];
        int y = tmp.second + dy[i];

        if (x >= 0 && x < 50 && y >= 0 && y < 50 && !used.at(x).at(y)) {
            false_cnt = 0;
            s += p.at(x).at(y);
            used.at(x).at(y) = true;
            q.pop();
            q.push(make_pair(x, y));
            for (int j = 0; j < 4; j++) {
                int xd = x + dx[j];
                int yd = y + dy[j];
                if (xd >= 0 && xd < 50 && yd >= 0 && yd < 50 && t.at(x).at(y) == t.at(xd).at(yd)) used.at(xd).at(yd) = true;
            }
            if (i == 0) ans_s += 'U';
            else if (i == 1) ans_s += 'L';
            else if (i == 2) ans_s += 'D';
            else ans_s += 'R';
        } else false_cnt++;
        cnt++;
    }
}

int main(){
    cin >> si >> sj;

    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            cin >> t.at(i).at(j);
        }
    }
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            cin >> p.at(i).at(j);
        }
    }
    solve();
    //ans_s.erase(ans_s.size()-1);
    cout << ans_s << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define _for(i,a,b) for(int i = (a); i < (b); i++)
#define _rep(i,a,b) for(int i = (a); i <= (b); i++)
#define all(v) (v).begin(), (v).end()

int ans1 = 0;
int A, B, H, W;

int vis[20][20];

void dfs1(int x, int y, int a1, int b1) {
    if(a1 < 0 or b1 < 0) return;
    if(y == W) x++, y = 0;
    if(x == H) return (void) ans1++;
    if(vis[x][y]) return dfs1(x, y+1, a1, b1);

    vis[x][y] = 1; dfs1(x, y+1, a1, b1-1);

    if(!vis[x+1][y]) vis[x+1][y] = 1, dfs1(x, y+1, a1-1, b1), vis[x+1][y] = 0;

    if(!vis[x][y+1]) vis[x][y+1] = 1, dfs1(x, y+1, a1-1, b1), vis[x][y+1] = 0;
    vis[x][y] = 0;
    return;
}

void taskD() {
    cin >> H >> W >> A >> B;//BF
    ans1 = 0;
    //dfs(0, 0, A, B);
    dfs1(0, 0, A, B);
    cout << ans1;
    return;
}

int main() {
    //ios_base::sync_with_stdio(false), cin.tie(nullptr);
    //taskPe26();
    taskD();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int N;
ll X;
ll a[101];
ll dp[101][101][101];

int main() {
    cin >> N >> X;
    REP(i, N) cin >> a[i];

    ll ans = LLINF;

    FOR(k, 1, N+1) {
        REP(i,N+1)REP(j,k+1)REP(l,k) dp[i][j][l] = -LLINF;
        dp[0][0][0] = 0;

        REP(i, N) {
            REP(cnt, k + 1) {
                REP(r, k) {
                    if(dp[i][cnt][r] == -LLINF) continue;

                    // えらぶ
                    if(cnt < k) {
                        ll cost = 0;
                        if(a[i] + r >= k) {
                            cost++;
                            ll remain = a[i] - (k - r);
                            cost += remain / k;
                        }
                        int nxt_r = (a[i] + r) % k;
                        if((dp[i][cnt][r] + cost) * k + nxt_r <= X) {
                            chmax(dp[i+1][cnt+1][nxt_r], dp[i][cnt][r] + cost);
                        }
                    }

                    // えらばない
                    chmax(dp[i+1][cnt][r], dp[i][cnt][r]);
                }
            }
        }

        if(dp[N][k][X%k] == -LLINF) continue;

        chmin(ans, (X - X % k - dp[N][k][X%k] * k) / k);

    }

    assert(ans != LLINF);
    cout << ans << endl;
}


#include <iostream>

namespace wxy{
    void main(){
        int a,b,x,y;
        std::cin >> a >> b;
        x = (a + b) / 2;
        y = a - x;
        std::cout << x << " " << y;
    }
}signed main(){wxy::main();return 0;}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>b)return 0; a=b; return 1;}
#define bitUP(x,a) ((x>>a)&1)
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double EPS = 1e-6;
long double PI = acos(-1);
const ll INF=(1LL<<62);
const int MAX=(1<<30);
constexpr ll MOD=1000000000+7;

inline void bin101(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

using pii=pair<int,int>;
using pil=pair<int,ll>;
using pli=pair<ll,int>;
using pll=pair<ll,ll>;
using psi=pair<string,int>;
using pis=pair<int,string>;
using psl=pair<string,ll>;
using pls=pair<ll,string>;
using pss=pair<string,string>;

using Graph=vector<vector<int>>;

template<typename T >
struct edge {
  int to;
  T cost;
  edge()=default;
  edge(int to, T cost) : to(to), cost(cost) {}

};
template<typename T>
using WeightGraph=vector<vector<edge<T>>>;

//1-indexed vector cin
template<typename T>
inline void vin1(vector<T> &v){
    for(size_t i=1;i<v.size();i++) cin>>v[i];
}

//0-indexed vector cin
template<typename T>
inline void vin0(vector<T> &v){
    for(size_t i=0;i<v.size();i++) cin>>v[i];
}

//1-indexed vector<vector> cin
template<typename T>
inline void vin1(vector<vector<T>> &v){
    for(size_t i=1;i<v.size();i++){
        for(size_t j=1;j<v[i].size();j++) cin>>v[i][j];
    }
}

//0-indexed vector<vector> cin
template<typename T>
inline void vin0(vector<vector<T>> &v){
    for(size_t i=0;i<v.size();i++){
        for(size_t j=0;j<v[i].size();j++) cin>>v[i][j];
    }
}

//要素数n 初期値x
template<typename T>
inline vector<T> vmake(size_t n,T x){
  return vector<T>(n,x);
}

//a,b,c,x data[a][b][c] 初期値x
template<typename... Args>
auto vmake(size_t n,Args... args){
    auto v=vmake(args...);
    return vector<decltype(v)>(n,move(v));
}

//pair cout
template<typename T, typename U>
inline ostream &operator<<(ostream &os,const pair<T,U> &p) {
  os<<p.first<<" "<<p.second;
  return os;
}

//pair cin
template<typename T, typename U>
inline istream &operator>>(istream &is,pair<T,U> &p) {
  is>>p.first>>p.second;
  return is;
}

//ソート
template<typename T>
inline void vsort(vector<T> &v){
    sort(v.begin(),v.end());
}

//逆順ソート
template<typename T>
inline void rvsort(vector<T> &v){
  sort(v.rbegin(),v.rend());
}

//1ビットの数を返す
inline int popcount(int x){
  return __builtin_popcount(x);
}
//1ビットの数を返す
inline int popcount(ll x){
  return __builtin_popcountll(x);
}

void solve(){
    int N,X;
    cin>>N>>X;
    vector<int> A(N);
    vin0(A);
    vector<int> ans;
    for(auto a:A){
        if(a!=X) ans.push_back(a);
    }
    for(int i=0;i<ans.size();i++){
        cout<<(i==0?"":" ")<<ans[i];
    }
    cout<<endl;
}

int main(){
    bin101();
    int T=1;
    //cin>>T;
    while(T--) solve();
}


#include <bits/stdc++.h>

#define INF 1e9
#define LINF (1LL << 63 - 1)
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
// #define chmax(a, b) a = max(a, b)
// #define chmin(a, b) a = min(a, b)
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())

using namespace std;
//using namespace atcoder;
using ld = long double;
using ll = long long;
using P = pair<ll, ll>;

template<typename T> bool chmin(T& a, const T& b) { if(a > b){ a = b; return 1;} return 0; }
template<typename T> bool chmax(T& a, const T& b) { if(a < b){ a = b; return 1;} return 0; }

const ll ZER = 0;
const ll MOD = 1e9 + 7;

ll dp[2020][2020];
int main(){
    // std::cin.tie(0);
    // std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m);
    rep(i, n)cin >> a[i];
    rep(i, m)cin >> b[i];
    rep(i, n)dp[i + 1][0] = i + 1;
    rep(j, m)dp[0][j + 1] = j + 1;
    rep(i, n){
        rep(j, m){
            if(a[i] == b[j]){
                dp[i + 1][j + 1] = dp[i][j];
            }
            else {
                dp[i + 1][j + 1] = min({dp[i][j], dp[i + 1][j], dp[i][j + 1]}) + 1;
            }
        }
    }
    cout << dp[n][m] << endl;
}

#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <list>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
void ex_gcd(ll a,ll b, ll& d,ll& x,ll& y){
  if(!b) {d=a;x=1;y=0;}
  else   {	ex_gcd(b,a%b,d,y,x);	y-=a/b*x;}
}
ll inv(ll a,ll n)  {
  ll d,x,y;	ex_gcd(a,n,d,x,y);
  return d==1?(x%n+n)%(n/d):-1;
}
const int maxn = 1005;
const int mod = 1000000007;

int a[maxn], b[maxn];
int f[maxn][maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=m;i++)cin>>b[i];
  int ret = 0;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
      f[i][j] = max(f[i-1][j],f[i][j-1]);
      f[i][j] = max(f[i][j],f[i-1][j-1]+2-(a[i]!=b[j]));
      ret = max(ret, f[i][j]);
    }
  cout<<n+m-ret<<endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pii pair<int, int>

const int maxN = 1e6 + 10;

int n;
int a[maxN];

int main()
{
	long long  v, t, s, d;

	cin>>v>>t>>s>>d;

	long long l = v*t;
	long long r  = v*s;

	if (d>r || d<l) printf("Yes\n"); else printf("No\n");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b;
  cin >> c >> d;
  cout << a * d - b * c;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
#define DEBUG_ON

int main(){
    ll n;
    cin>>n;
    vector <ll> a(n);

    ll sum=0;
    ll ind=0;
    ll yoko=0;
    ll ind_y=999;
    ll yokom=0;
    ll MAX;
    ll robo=0;
    ll hasi=0;
    vector <ll> ma(n);
    rep(i,n){
        cin>>a.at(i);
        sum+=a.at(i);
        if(i>=1){
            if(sum>ma.at(i-1)){
                ma.at(i)=sum;
            }
            else{
                ma.at(i)=ma.at(i-1);
            }
        }
        else{
            if(sum>=0){
                ma.at(i)=sum;
            }
            else{
                ma.at(i)=0;
            }
        }

        robo = max(robo, hasi + ma.at(i));
        hasi += sum;
    }
    cout<<robo;

    return 0;
}

//Code by @Luckyniu (<Luogu uid>=142548)
#include<bits/stdc++.h>
#define int long long
#define in long double
#define inf 0x3f3f3f3f3f3f
#define ie inline
#define rg register
#define debug fprintf(stderr,"passed [%s] in line %d\n",__FUNCTION__,__LINE__);
using namespace std;
ie int power(int b, int k){
	if(k==1) return b;
	if(k&1){
		return power(power(b,k>>1),2);
	}
	return power(power(b,(k-1)>>1),2)*b;
}
ie void read(int& tp){
    tp=0;
	int pt=1;
    char cha=getchar();
    while(cha<'0'||cha>'9'){
	    if(cha=='-') pt=-1;
	    cha=getchar();
    }
    while(cha>='0'&&cha<='9'){
		tp=tp*10+cha-'0';
		cha=getchar();
	}
	tp*=pt;
}
ie void write(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
int t;
int n;
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	read(t);
	while(t--){
		read(n);
		if(n&1) puts("Odd");
		else if((n/2)&1) puts("Same");
		else puts("Even");
	}
	return 0;
}