#include<bits/stdc++.h>
using namespace std;
vector<char> opers;
int modulo(1e9 + 7);
typedef long long LL;
int pw(int x, int n) {
	int res(1);
	while(n) {
		if(n & 1)
			res = (LL)res * x % modulo;
		x = (LL)x * x % modulo;
		n /= 2;
	}
	return res;
}
inline bool isDigit(char c) {
	return c >= '0' && c <= '9';
}
const int N(111111);
char st[N];
struct Opad {
	string str;
	int val, mul;
	Opad() {
		val = 0;
		mul = 1;
	}
};
vector<Opad> opads;
void operate() {
	Opad o1, o2;
	o2 = opads.back();
	opads.pop_back();
	o1 = opads.back();
	opads.pop_back();
	if(opers.back() == '+') {
		Opad res;
		res.val = ((LL)o1.val * o2.mul + o2.val) % modulo;
		res.mul = (LL)o1.mul * o2.mul % modulo;
		opads.push_back(res);
	}else {
		Opad res;
		for(int i((int)o1.str.size() - 1); i >= 0; i--) {
			for(int j(0); j < (int)o1.str[i] - '0'; j++) {
				res.val = ((LL)res.val * o2.mul + o2.val) % modulo;
				res.mul = ((LL)res.mul * o2.mul) % modulo;
			}
			int mul(o2.mul), add(o2.val);
			for(int j(0); j < 9; j++) {
				o2.mul = ((LL)mul * o2.mul) % modulo;
				o2.val = ((LL)mul * o2.val + add) % modulo;
			}
		}
		opads.push_back(res);
	}
	opers.pop_back();
}
Opad calc(const string & a) {
	Opad res;
	res.str = a;
	for(int i(0); i < (int)a.size(); i++) {
		res.mul = res.mul * 10ll % modulo;
		res.val = (res.val * 10ll + a[i] - '0') % modulo;
	}
	return res;
}
Opad calc(const string & le, const string & ri) {
	//cout << le << ' ' << ri << endl;
	Opad res;
	Opad a(calc(le)), b(calc(ri));
	int phil(0), phir(0);
	for(int i(0); i < (int)le.size(); i++) {
		phil = ((LL)phil * 10ll + le[i] - '0') % (modulo - 1);
	}
	for(int i(0); i < (int)ri.size(); i++) {
		phir = ((LL)phir * 10ll + ri[i] - '0') % (modulo - 1);
	}
	//cout << a.val << ' ' << b.mul << endl;
	int cur(1), curphi(1);
	for(int i(1); i < le.size(); i++) {
		cur = cur * 10ll % modulo;
		curphi = curphi * 10ll % (modulo - 1);
	}
	for(int len(le.size()); len <= ri.size(); len++) {
		int leval, rival, lephi, riphi;
		if(len == le.size()) {
			leval = a.val;
			lephi = phil;
		}else {
			leval = cur;
			lephi = curphi;
		}
		if(len == ri.size()) {
			rival = b.val;
			riphi = phir;
		}else {
			rival = (cur * 10ll + modulo - 1) % modulo;
			riphi = (curphi * 10ll + modulo - 2) % (modulo - 1);
		}
		//printf("%d %d %d %d\n", leval, lephi, rival, riphi);
		int bs(pw(10, len));
		//cout << bs << endl;
		//cout << (rival + 1ll) * ((pw(bs, (riphi - lephi + modulo) % (modulo - 1)) - 1ll + modulo) * pw(bs - 1, modulo - 2) % modulo) % modulo << endl;
		//cout << ((rival - leval + 1ll + modulo) * pw(bs, (rival - leval + 1 + modulo) % (modulo - 1)) - (rival - leval + 2ll + modulo) * pw(bs, (riphi - lephi + modulo) % (modulo - 1)) + 1) % modulo * pw(bs - 1, modulo - 2) % modulo * pw(bs - 1, modulo - 2) % modulo << endl;
		//cout << ((rival + 1ll) * ((pw(bs, (riphi - lephi + modulo) % (modulo - 1)) - 1ll + modulo) * pw(bs - 1, modulo - 2) % modulo) % modulo - ((rival - leval + 1ll + modulo) * pw(bs, (rival - leval + 1 + modulo) % (modulo - 1)) - (rival - leval + 2ll + modulo) * pw(bs, (riphi - lephi + modulo) % (modulo - 1)) + 1) % modulo * pw(bs - 1, modulo - 2) % modulo * pw(bs - 1, modulo - 2) % modulo) << endl;
		int val = (((rival + 1ll) * ((pw(bs, (riphi - lephi + modulo) % (modulo - 1)) - 1ll + modulo) * pw(bs - 1, modulo - 2) % modulo) % modulo - ((rival - leval + 1ll + modulo) * pw(bs, (riphi - lephi + 1 + modulo) % (modulo - 1)) - (rival - leval + 2ll + modulo) * pw(bs, (riphi - lephi + modulo) % (modulo - 1)) + 1) % modulo * pw(bs - 1, modulo - 2) % modulo * pw(bs - 1, modulo - 2) % modulo) + modulo) % modulo;
		int mul = pw(bs, (riphi - lephi + modulo) % (modulo - 1));
		res.val = ((LL)res.val * mul + val) % modulo;
		res.mul = (LL)res.mul * mul % modulo;
		//cout << val << ' ' << mul << endl;
		cur = cur * 10ll % modulo;
		curphi = curphi * 10ll % (modulo - 1);
	}
	return res;
}
int main() {
	scanf("%s", st);
	int len(strlen(st));
	for(int i(0); i < len; i++) {
		if(isDigit(st[i])) {
			string s;
			int j(i);
			for( ; isDigit(st[j]); j++)
				s.push_back(st[j]);
			if(st[j] == '-') {
				string t;
				for(j++; isDigit(st[j]); j++)
					t.push_back(st[j]);
				opads.push_back(calc(s, t));
			}else {
				opads.push_back(calc(s));
			}
			i = j - 1;
		}else if(st[i] == '(') {
			opers.push_back('(');
		}else if(st[i] == '+') {
			opers.push_back('+');
		}else if(st[i] == ')') {
			while(opers.back() != '(') {
				operate();
			}
			operate();
		}
	}
	while(opers.size())
		operate();
	cout << opads.back().val << endl;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline void read(long long &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}

inline void read(int &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}

inline void write(long long x){
    static const long long maxlen=100;
    static char s[maxlen];
        if (x<0) {   putchar('-'); x=-x;}
    if(!x){ putchar('0'); return; }
    long long len=0; for(;x;x/=10) s[len++]=x % 10+'0';
    for(long long i=len-1;i>=0;--i) putchar(s[i]);
}

#include <algorithm>  // std::swap
#include <utility>  // std::pair, std::make_pair

// Stein's algorithm, find the greatest common divisor (GCD) of m and n.
// The result will always be non-negative.
// If m or n is zero, the result will be the bigger one.
// This implementation is 1 time faster than GNU STL std::gcd (C++17).
// @param m: m above.
// @param n: n above.
// @return: GCD(m, n), always positive.
template <typename T>
T gcd(T m, T n) {
  if (!m || !n) return m | n;
  if (m < 0) m = -m;
  if (n < 0) n = -n;
  long long p = 0;
  while (!(m & 1) && !(n & 1))
    m >>= 1, n >>= 1, ++p;
  while (n) {
    while (!(m & 1)) m >>= 1;
    while (!(n & 1)) n >>= 1;
    if (m >= n) std::swap(m, n);
    n = (n - m) >> 1;
  }
  return m << p;
}

// As for equation:
//   mx + ny = gcd(m, n)
// @param m: m above.
// @param n: n above.
// @return: r = (gcd(m, n), (x, y))
//          r.first is gcd
//          r.second.first  is x
//          r.second.second is y
// C++98 has no std::tuple, just put up with it.
template <typename T>
std::pair<T, std::pair<T, T> > exgcd(T m, T n) {
    using std::make_pair;
    T x = 0, y = 1, xp = 1, yp = 0, xt, yt;
    for (T r = m % n, q = m / n; r; ) {
        xt = xp - q * x, xp = x, x = xt;
        yt = yp - q * y, yp = y, y = yt;
        m = n, n = r, r = m % n, q = m / n;
    }
    return make_pair(n, make_pair(x, y));
}

// As for congruence equation
//   mx = gcd(m, n) (mod n)
// @param m: m above.
// @param n: n above.
// @return: x above.
template <typename T>
T modinv(T m, T n) {
  typedef std::pair<T, std::pair<T, T> > triple;
  triple gxy = exgcd(m, n);
  T loop = n / gxy.first;
  T inv = gxy.second.first;
  inv = inv % loop;
  return inv < 0 ? inv + loop : inv;
}

const long long MAXN = 301000;

const long long P = 998244353 ;

long long n;
vector<long long> son[ MAXN ];
long long f[ MAXN ][ 3 ];

void dfs(long long x,long long fa){
f[x][1]=1;
f[x][2]=0;
long long T=1;
for (long long i=0;i<son[x].size();i++)
	if ( son[x][i]!= fa )
		{
			long long y=son[x][i];
			dfs(y,x);
			T=T*f[y][0]%P;
			f[x][1]=f[x][1]*(f[y][0]+f[y][2])%P;
		}
for (long long i=0;i<son[x].size();i++)
	if ( son[x][i]!=fa )
		{
			long long y=son[x][i];
			f[x][2]=(f[x][2]+modinv( f[y][0]+f[y][2] , P )*f[y][1]%P*f[x][1]%P)%P;
		}
f[x][0]=(T+f[x][2])%P;
}

int main(){
	//puts("&");
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	//puts("--------------");
	read(n);
	for (long long i=1;i<n;i++)
		{
			long long a,b;
			read(a);read(b);
			son[a].push_back(b);
			son[b].push_back(a);
		}
	dfs(1,0);
	printf("%I64d\n",f[1][0]%P);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n, t = 1, i = 0;
    cin >> n;
    while(t <= n){
        ++i;
        t+=(1 + i+1)*(i+1)/2;
    }
    cout << i;

}


#include<bits/stdc++.h>

#define ll              long long int
#define ull             unsigned long long int
#define pii             pair < int, int>
#define pll             pair < ll, ll>
#define sc              scanf
#define scin(x)         sc("%d",&(x))
#define scln(x)         sc("%lld",&(x))
#define pf              printf
#define ms(a,b)         memset(a,b,sizeof(a))
#define pb(a)           push_back(a)
#define mp              make_pair
#define db              double
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define vi              vector< int >
#define vl              vector< ll >
#define vii             vector<vector< int > >
#define vll             vector<vector< ll > >
#define DBG             pf("HI\n")
#define MOD             1000000007
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define RUN_CASE(t,T)   for(__typeof(t) t=1;t<=T;t++)
#define CASE(t)         printf("Case %d: ",t)
#define CASEL(t)        printf("Case %d:\n",t)
#define intlimit        2147483648
#define longlimit       9223372036854775808
#define infinity        (1<<28)
#define gcd(a, b)       __gcd(a,b)
#define lcm(a, b)       ((a)*(b)/gcd(a,b))
#define mx              1234567899
#define PI              2*acos(0.0)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for(__typeof(i) i=a; i<=b; i++)
#define rev(i,a,b)      for(__typeof(i) i=a; i>=b; i--)

using namespace std;

int main()
{
    int n,cnt=1;
    string s;
    bool flag=0;
    cin>>n;
    cin>>s;
    if(n==1 && s[0]=='0')
    {
        pf("NO\n");
        return 0;
    }
    if(n==2)
    {
        if(s[0]!=s[1])
        {
            pf("YES\n");
            return 0;
        }
    }
///    int cnt=0;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='1')
        {
            cnt=0;
            if(i==n-1 && s[i-1]=='1')
            {
                flag=1;
                break;
            }
            if(i==0 && s[i+1]=='1')
            {
                flag=1;
                break;
            }
            if(s[i-1]=='1' || s[i+1]=='1')
            {
                flag=1;
                break;
            }

        }
        else
            cnt++;
        if(cnt>2)
        {
            flag=1;
            break;
        }

    }
    if(flag==1 || cnt>1)
        pf("NO\n");
    else
        pf("YES\n");
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lii;
typedef unsigned long long int uli;

uli n, b;
vector<uli> factores;
vector<uli> exponentes;

void factorizar(uli n)
{
    for (uli i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            factores.push_back(i);
            exponentes.push_back(0);
            while (n % i == 0)
            {
                n /= i;
                exponentes[exponentes.size() - 1]++;
            }
        }
    }
    if (n != 1)
    {
        factores.push_back(n);
        exponentes.push_back(1);
    }
}

uli apariciones(uli a)
{
    uli contador = 0;
    for(uli i=a; i<= n; i*=a){
        contador += n/i;
        uli x = i*a;
        if(x/a != i) break;
    }
    return contador;
}

int main(void)
{
    cin >> n >> b;
    factorizar(b);
    uli minimo = 1000000000000000000;
    for (uli i = 0; i < factores.size(); i++)
    {
        uli aparece = apariciones(factores[i]);
        if (aparece / exponentes[i] < minimo)
            minimo = aparece / exponentes[i];
    }
    cout << minimo;
}


#include <stdio.h>

int main()
{
	int n, l, r;
	long long int min = 0, max = 0;

	scanf ("%d %d %d", &n, &l, &r);

    int cnt = 2;

    for (int i = 1; i < l; i++, cnt *= 2)
        min += cnt;

    min += n - l + 1;

    cnt = 1;

    for (int i = 0; i < r; i++, cnt *= 2)
        max += cnt;

    cnt /= 2;

    max += cnt * (n - r);

    printf ("%lld %lld", min, max);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1.5e5+10;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,k,dfn[N],low[N],tim,fa[N],anc[N][20],dep[N],s[N],t[N];
ll ans;
vi E[N],vec[N];

void dfs(int u,int ff) {
	fa[u]=anc[u][0]=ff;dep[u]=dep[ff]+1;dfn[u]=++tim;
	for(int i=1;i<=17;i++) anc[u][i]=anc[anc[u][i-1]][i-1];
	for(auto v:E[u])
		if(v!=ff) dfs(v,u);
	low[u]=tim;
}

int lca(int u,int v) {
	if(dep[u]<dep[v]) swap(u,v);
	int c=dep[u]-dep[v];
	for(int i=17;~i;i--)
		if(c>>i&1) u=anc[u][i];
	if(u==v) return u;
	for(int i=17;~i;i--)
		if(anc[u][i]!=anc[v][i]) u=anc[u][i],v=anc[v][i];
	return fa[u];
}

int jump(int u,int k) {
	for(int i=17;~i;i--)
		if(k>>i&1) u=anc[u][i];
	return u;
}

int move(int u,int v,int k) {
	int p=lca(u,v),dist=dep[u]+dep[v]-2*dep[p];
	if(dist<k) return -1;
	if(dep[u]-dep[p]>=k) return jump(u,k);
	return jump(v,dist-k);
}

namespace fenw {
	int c[N];
	vector<pii> opts;

	void modify(int p,int v,bool fl=1) {
		if(fl) opts.pb(mp(p,v));
		while(p<=n) c[p]+=v,p+=p&-p;
	}

	int query(int p) {
		int ret=0;
		while(p) ret+=c[p],p-=p&-p;
		return ret;
	}

	void clear() {
		for(auto t:opts) modify(t.fi,-t.se,0);
		opts.clear();
	}
}

namespace S1 {
	int id[N];

	bool cmp(int x,int y) {
		return dep[x]>dep[y];
	}

	void solve() {
		for(int i=1;i<=n;i++) id[i]=i;
		sort(id+1,id+n+1,cmp);
		for(int cur=1;cur<=n;cur++) {
			int u=id[cur];
			for(auto i:vec[u]) {
				ans+=fenw::query(dfn[s[i]]);
				ans+=fenw::query(dfn[t[i]]);
			}
			for(auto i:vec[u]) {
				int tmp=move(u,s[i],k);
				if(tmp!=-1) fenw::modify(dfn[tmp],1),fenw::modify(low[tmp]+1,-1);
				tmp=move(u,t[i],k);
				if(tmp!=-1) fenw::modify(dfn[tmp],1),fenw::modify(low[tmp]+1,-1);
			}
		}
		fenw::clear();
	}
}

namespace seg {
	int sum[N*50],ls[N*50],rs[N*50],tt;

	void insert(int p,int &x,int l=1,int r=n) {
		++tt;ls[tt]=ls[x];rs[tt]=rs[x];sum[tt]=sum[x]+1;x=tt;
		if(l==r) return;
		int mid=(l+r)>>1;
		p<=mid?insert(p,ls[x],l,mid):insert(p,rs[x],mid+1,r);
	}

	int query(int L,int R,int x,int l=1,int r=n) {
		if(!x) return 0;
		if(L<=l&&r<=R) return sum[x];
		int mid=(l+r)>>1,ret=0;
		if(L<=mid) ret+=query(L,R,ls[x],l,mid);
		if(R>mid) ret+=query(L,R,rs[x],mid+1,r);
		return ret;
	}

	int merge(int x,int y) {
		if(!x||!y) return x|y;
		ls[x]=merge(ls[x],ls[y]);
		rs[x]=merge(rs[x],rs[y]);
		sum[x]+=sum[y];
		return x;
	}

	void clear() {
		for(int i=1;i<=tt;i++) sum[i]=ls[i]=rs[i]=0;
		tt=0;
	}
}

namespace vir {
	int rt[N],p;
	vi E[N],need_clr,vec[N],all[N];

	bool cmp(int x,int y) {
		return dfn[x]<dfn[y];
	}

	void build(vi nodes) {
		sort(nodes.begin(),nodes.end(),cmp);
		for(int i=sz(nodes)-2;~i;i--) nodes.pb(lca(nodes[i],nodes[i+1]));
		sort(nodes.begin(),nodes.end(),cmp);
		nodes.erase(unique(nodes.begin(),nodes.end()),nodes.end());
		need_clr=nodes;
		static int st[N];int tp=0;p=nodes[0];
		for(auto u:nodes) {
			while(tp&&low[st[tp]]<dfn[u]) --tp;
			if(tp) E[st[tp]].pb(u); st[++tp]=u;
		}
	}

	void add(int x,int id) {
		vec[x].pb(id);
	}

	void dfs(int u) {
		for(auto i:vec[u]) {
			int b=move(u,t[i],max(k,dep[u]-dep[p]+1));
			if(b!=-1&&u!=p) ans+=seg::query(dfn[b],low[b],rt[u]);
			seg::insert(dfn[t[i]],rt[u]);
			all[u].pb(i);
		}
		for(auto v:E[u]) {
			dfs(v);
			if(sz(all[u])>sz(all[v])) {
				for(auto i:all[v]) {
					int b=move(u,t[i],max(k,dep[u]-dep[p]+1));
					if(b!=-1&&u!=p) ans+=seg::query(dfn[b],low[b],rt[u]);
				}
				for(auto i:all[v]) all[u].pb(i);
			}
			else {
				for(auto i:all[u]) {
					int b=move(u,t[i],max(k,dep[u]-dep[p]+1));
					if(b!=-1&&u!=p) ans+=seg::query(dfn[b],low[b],rt[v]);
				}
				for(auto i:all[u]) all[v].pb(i);
				swap(all[u],all[v]);
			}
			rt[u]=seg::merge(rt[u],rt[v]);
		}
	}

	void clear() {
		for(auto u:need_clr) {
			rt[u]=0;E[u].clear();vec[u].clear();all[u].clear();
		}
	}
}

namespace S2 {
	int cur;

	pii get(int i) {
		if(s[i]==cur) return mp(dfn[cur],dfn[t[i]]);
		return mp(dfn[move(cur,s[i],1)],dfn[move(cur,t[i],1)]);
	}

	bool cmp(int x,int y) {
		return get(x)<get(y);
	}

	void solve() {
		for(int u=1;u<=n;u++) {
			cur=u;sort(vec[u].begin(),vec[u].end(),cmp);
			for(int l=0,r;l<sz(vec[u]);l=r) {
				r=l+1;
				if(s[vec[u][l]]!=u) {
					while(r<sz(vec[u])&&get(vec[u][l])==get(vec[u][r])) ++r;
				}
				for(int o=l;o<r;o++) {
					int i=vec[u][o];
					ans+=fenw::query(dfn[s[i]]);
					ans+=fenw::query(dfn[t[i]]);
				}
				for(int o=l;o<r;o++) {
					int i=vec[u][o],tmp=move(u,s[i],k);
					if(tmp!=-1) fenw::modify(dfn[tmp],1),fenw::modify(low[tmp]+1,-1);
					tmp=move(u,t[i],k);
					if(tmp!=-1) fenw::modify(dfn[tmp],1),fenw::modify(low[tmp]+1,-1);
				}
			}
			fenw::clear();
			vi all={u};
			for(auto i:vec[u]) if(s[i]!=u) all.pb(s[i]),all.pb(t[i]);
			vir::build(all);
			for(auto i:vec[u]) if(s[i]!=u) vir::add(s[i],i);
			vir::dfs(u);
			vir::clear();seg::clear();
		}
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	cin>>n>>m>>k;
	for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
	dfs(1,0);
	for(int i=1;i<=m;i++) {
		s[i]=gi(),t[i]=gi();
		if(dfn[s[i]]>dfn[t[i]]) swap(s[i],t[i]);
		vec[lca(s[i],t[i])].pb(i);
	}
	S1::solve();
	S2::solve();cout<<ans;
	return 0;
}


#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

long double c(int n, int m) {
	if (m < 0 || m > n) {
		return 0;
	} else {
		long double c = 0;
		for (int i = 1; i <= m; i++) {
			c += log10(n - i + 1);
			c -= log10(i);
		}
		return pow(10, c);
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	long double ans = 0;
	for (int i = 0; i <= n; i++) {
		ans += i * i * c(n * m - m, n - i) * c(m, i);
	}
	ans /= c(n * m, n);
	ans /= n;
	printf("%.10f\n", (double) ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef long long INT;
int f[110];
int main(){
#ifndef ONLINE_JUDGE
	freopen("a.txt","r",stdin);
#endif
	int n,m;
	cin>>n>>m;
	if(m==0) {
		if(n>1) puts("-1 -1");
		else puts("0 0");
		return 0;
	}
	if(m>n*9){
		printf("-1 -1");
		return 0;
	}
	if(m<=9*n and m>=9*(n-1)+1){
		for(int i=1;i<n;i++) f[i]=9;
		f[0]=m-9*(n-1);
		for(int i=0;i<n;i++) cout<<f[i];
		cout<<" ";
		for(int i=n-1;i>=0;i--) cout<<f[i];
		return 0;
	}
	else {
		m--;
		cerr<<m;
		f[0]=1;
		for(int i=n-1;i>0;i--){
			if(m>=9) {f[i]=9;m-=9;}
			else {
				f[i]=m;
				break;
			}
		}
	}
	for(int i=0;i<n;i++) cout<<f[i];
	cout<<" ";
	int t=0;
	for(int i=n-1;i>0;i--){
		if(f[i]!=9) {
			f[i]++;
			f[0]=0;
			break;
		}
	}
	for(int i=n-1;i>=0;i--) cout<<f[i];
}


//every day every hour turn the pain into power
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	long long n, a, b, c[110], x, y, k, sum = 0, sum2 = 0;
	cin >> n;

	for (int i = 0; i < n; ++i)
		cin >> c[i];
	cin >> x >> y;

	bool f = 0;
	for (int i = 0; i < n; ++i)
	{
		if (sum >= x && sum <= y)
		{
			for (int j = i; j < n; ++j)
				sum2 += c[j];
			if (sum2 >= x && sum2 <= y)
			{
				f = 1;
				k = i + 1;
				break;
			}
			sum2 = 0;
		}
		sum += c[i];
	}

	if (f)
		cout << k;
	else
		cout << 0;

	cin >> n;
	return 0;
}


#include"iostream"
#include"algorithm"
#include"vector"
#include"queue"
#include"map"
#include"cstdio"
#include"string"
#include"stack"
#include"set"
#include"cstring"
using namespace std;
int main()
{
	int m,n,k[12],h;
	map<int,int>p;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&k[i]);
		p[k[i]]++;
	}
		for(int i=0;i<m;i++)
		{
		scanf("%d",&h);
		p[h]++;
		}
		int g=0;
		for(int i=0;i<n;i++)
			if(p[k[i]]==2)
			{printf("%d ",k[i]);g=1;}
		if(g==0)
	printf("\n");
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
__int64 a[5];
int main(){
	int i,j,k;
	for(i=0;i<3;i++) scanf("%I64d",&a[i]);
	sort(a,a+3);
	if((a[1]-a[0])%2==0) printf("%I64d\n",a[1]);
	else printf("%I64d\n",a[2]);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = (ll) 1e9 + 7;
#define pb push_back
#define pf push_front
typedef deque <ll> dll;
typedef deque <int> di;
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) //traverse through all container
#define all(c) c.begin(), c.end()
ll docheck(ll n, ll k)
{
    ll ans=0;
    if(k>=n)
        return n;
    ll rem=n;
    while(k<rem)
    {
        ans+=k;
        rem-=k;
        rem=rem-rem/10;
    }
    ans+=rem;
    return ans;
}
ll binarySearch(ll n, ll k, ll l, ll r)
{
   if (r >= l)
   {
        ll mid = l + (r - l)/2;
        ll num = docheck(n, mid);

        if(num == (n + 1)/2)
            return mid;
        else if(l==r-1)
            return mid+1;

        if (num > (n+1)/2)
            return binarySearch(n, (l+mid)/2, l, mid);

        return binarySearch(n, (r+mid+1)/2, mid, r);
   }
    return k;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, l, r;
    cin>>n;
    l=1;
    r=n;
    // cout<<docheck(n,k);
    if(n<=10)
        cout<<"1";
    else
    cout<<binarySearch(n, l+(r-l)/2, l, r);
    return 0;
}


#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define y1 asjdlfaskavslbcjasndscf
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter set< int >::iterator
#define iter1 multiset<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=1e6+7;
const int inf=1e9+1e9;
const int mod=1e9+7;
const ld eps=1e-9;

//const int MAX_MEM=4e8;
//int mpos=0;
//char mem[MAX_MEM];
//
//inline void * operator new(size_t n){
//    char *res=mem+mpos;
//    mpos+=n;
//    if (mpos>=MAX_MEM){
//        cout<<"BAD"<<endl;
//        exit(0);
//    }
//    return (void*)res;
//}
//
//inline void operator delete(void *) {}

ll a[N];
vector< pair<ll,int> >b1,b2;
int kol2[65538],kol1[65538];
int f[65338];
ll n,X,Y;

main ()
{
    //ios;
    cin>>n>>X>>Y;
    ll XX=X,YY=Y;
    for (int i=1;i<=n;++i){
        cin>>a[i];
    }
    if (Y%X!=0){
        cout<<0<<endl;
        exit(0);
    }
    for (ll i=2;i*i*i<=Y;++i){
        if (Y%i==0){
            int kol=0;
            while(Y%i==0){
                ++kol;
                Y/=i;
            }
            b2.pb({i,kol});
        }
    }
    if (Y>1){
        ll f=sqrt(Y);
        if (f*f==Y){
            b2.pb({f,2});
            Y=1;
        }
        else {
            ll l=__gcd(X,Y);
            if (l!=1 && l!=Y){
                b2.pb({l,1});
                b2.pb({Y/l,1});
                Y=1;
            }
            else {
                for (int i=1;i<=n;++i){
                    ll x=a[i];
                    int l=__gcd(x,Y);
                    if (l!=1 && l!=Y){
                        b2.pb({l,1});
                        b2.pb({Y/l,1});
                        Y=1;
                        break;
                    }
                }
            }
            if (Y>1){
                b2.pb({Y,1});
                Y=1;
            }
        }
    }
    b1.resize((int)b2.size(),{0,0});
    for (int i=0;i<b1.size();++i){
        int kol=0;
        b1[i].ff=b2[i].ff;
        while(X%b1[i].ff==0){
            X/=b1[i].ff;
            ++kol;
        }
        b1[i].ss=kol;
    }
    X=XX;
    Y=YY;
    for (int i=1;i<=n;++i){
        if (a[i]%X!=0)continue;
        ll x=a[i];
        int mask1=0;
        for (int j=0;j<b1.size();++j){
            if (b1[j].ss<b2[j].ss){
                int kol=0;
                while(x%b1[j].ff==0){
                    x/=b1[j].ff;
                    ++kol;
                }
                if (kol>b1[j].ss){
                    mask1|=(1LL<<j);
                }
            }
        }
        kol1[mask1]++;
    }
    for (int i=1;i<=n;++i){
        if (Y%a[i]!=0)continue;
        ll x=a[i];
        int mask1=0;
        for (int j=0;j<b2.size();++j){
            if (b1[j].ss<b2[j].ss){
                int kol=0;
                while(x%b2[j].ff==0){
                    x/=b2[j].ff;
                    ++kol;
                }
                if (kol<b2[j].ss){
                    mask1|=(1LL<<j);
                }
            }
        }
        for (int j=0;j<b2.size();++j){
            mask1^=(1LL<<j);
        }
        kol2[mask1]++;
    }
    int m=(int)b1.size();
    for (int mask=0;mask<(1LL<<m);++mask){
        f[mask]=kol1[mask];
    }
    for (int bit=0;bit<m;++bit){
        for (int mask=0;mask<(1LL<<m);++mask){
            if ((mask&(1LL<<bit))){
                f[mask]+=f[(mask^(1LL<<bit))];
            }
        }
    }
    ll ans=0;
    for (int mask=0;mask<(1LL<<m);++mask){
        ans+=(ll)f[mask]*(ll)kol2[mask];
    }
    cout<<ans<<endl;
}


#include <iostream>

using namespace std;

int main()
{
    long int k;
    long int n;
    cin>>n>>k;
    while(k!=0){
    if(n%10==0){
    n=n/10;
    k=k-1;
    }else{
    if(k>=n%10){k=k-n%10;
    n=n-n%10;
    }else{k=k-1;
    n=n-1;
    }

    }
    }
    cout << n << endl;
    return 0;
}


//region trash
#ifndef LOCAL
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define DB(x){if(cond)cerr<<__LINE__<<" "<<#x<<" " <<x<<endl;}
#else
#define DB(x){}
#endif
#define REP(i,b)for(auto i=0;i<(b);++i)
#define FOR(i,a,b)for(auto i=(a);i<=(b);++i)
#define FORD(i,a,b)for(auto i=(a);i>=(b);--i)
#define FORDE(rit,x)for(auto rit=(x).rbegin();rit!=(x).rend();rit++)
#define VV vector
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
template<typename X, typename Y>bool MA(X&a,Y b){if(a<b){a=b;return true;} return false;}
template<typename X, typename Y>bool MI(X&a,Y b){if(a>b){a=b;return true;} return false;}
typedef long long LL,ll;typedef long double LD,ld;
typedef array<int,2>I2,i2;typedef VV<int>VI,vi;
using namespace std;
int cond=0;
//endregion

int mode=1;

struct Solver {
  int N;
  VV<VV<int>>A;
  void solve() {
    cin>>N;
    A.resize(N,VV<int>(N));
    REP(r,N)REP(c,N) cin >> A[r][c];

    cout<<"B"<<endl;
    char x; cin>>x;
    bool inc = x != 'I';
    int node;cin>>node;node--;

    int how = (node < N && inc) || (node >= N && !inc);
    DB(how);

    VV<int>PREF_A(N,-1),PREF_B(N,-1);
    VV<int>CAND_A(N,0);

    VV<VV<int>>ORD(N);
    REP(a, N) {
      ORD[a].resize(N);
      iota(ALL(ORD[a]), 0);

      sort(ALL(ORD[a]),
          [&](int le, int ri) {
            if (how == 1) return A[a][le] > A[a][ri];
            else return A[a][le] < A[a][ri];
          });
      REP(n,N)DB(a<<" "<<ORD[a][n]);
    }

    REP(iter,3*N) {
      REP(a, N) {
        if (PREF_A[a] != -1) continue;
        for(;CAND_A[a]<N;CAND_A[a]++) {
          int b = ORD[a][CAND_A[a]];
          if (PREF_B[b] == -1) {
            PREF_A[a] = b;
            PREF_B[b] = a;
            CAND_A[a]++;
            break;
          }
          else {
            int old_a = PREF_B[b];
            int s1 = A[a][b];
            int s2 = A[old_a][b];
            if (how == 1 && s1 < s2 || how == 0 && s1 > s2) {
              PREF_A[old_a] = -1;
              PREF_A[a] = b;
              PREF_B[b] = a;
              CAND_A[a]++;
              break;
            }
          }
        }
      }
    }
    REP(n,N) assert(PREF_A[n] != -1);
    REP(n,N) assert(PREF_B[n] != -1);
    REP(n,N) DB(n<<" "<<PREF_A[n]);
    REP(n,N) DB(n<<" "<<PREF_B[n]);
    DB(node)
    while (node >= 0) {
      if (node < N) cout<<PREF_A[node]+1+N<<endl;
      else cout<<PREF_B[node-N]+1<<endl;

      cin >> node; node--;
    }

    DB(N);
    REP(n,N){ DB(n<<" "<<PREF_A[n]); }
    REP(n,N){ DB(n<<" "<<PREF_B[n]); }

  }
};

int main(int argc,char** argv){
  struct Solver2 {
    void gen() {}
    void brute() {}
  };
  random_device rd{};
  uint64_t seed = (uint64_t)rd()
      ^ (uint64_t)std::chrono::steady_clock::now().time_since_epoch().count()
      ^ (uint64_t)__builtin_ia32_rdtsc()
      ^ (uint64_t)make_unique<char>().get();
  srand(seed); mt19937 rng(seed);

  ios::sync_with_stdio(false),cin.tie(nullptr);
  FOR(a,1,argc-1){if(argv[a][0]=='g') { Solver2 solver; solver.gen(); return 0; }}
  FOR(a,1,argc-1){if(argv[a][0]=='q') cond=1U<<30U;}
  cout.setf(ios::fixed),cout.precision(10);
  int t{};if(mode >= 1)cin>>t;else t=1;
  bool isBrute=false;FOR(a,1,argc-1)if(argv[a][0]=='b')isBrute=true;
  FOR(i,1,t){if(cond)cerr<<__LINE__<<" "<<i<<endl;if(mode == 2)cout<<"Case #"<<i<<": ";
    auto solver = make_unique<Solver>();
    auto solver2 = make_unique<Solver2>();
    if (isBrute)
      solver2->brute();
    else
      solver->solve();
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define I insert
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector< pll >

ll P,Q;

ll gcdExtended(ll a, ll b, ll *x, ll *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0LL;
        *y = 1LL;
        return b;
    }

    ll x1, y1; // To store results of recursive call
    ll gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;
 	return gcd;
}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n,m,x,y,vx,vy,a,b,c,d,e,f,i,j,k;ll n1,m1;
	cin>>n>>m>>x>>y>>vx>>vy;//a=__gcd(x,(__gcd(y,__gcd(m,n))));x/=a;y/=a;m/=a;n/=a;
	if(vx==1){
		if(vy==1){
			a=x-y;
			b=__gcd(m,n);if(abs(a)%b){cout<<"-1";return 0;}
			n1=n;m1=m;m=m/b;n=n/b;a=a/b;b=1;
			gcdExtended(n,m,&P,&Q);
		//	cout<<P<<" "<<Q<<"\n";
			c=a/b;P=P*c;Q*=c;Q*=-1;
		//	cout<<P<<" "<<Q<<"\n";
			if(P<=0||Q<=0){
				e=f=0;
				if(P<=0)e=ceil(abs(P)/(m*1.0)+1e-15);
				if(Q<=0)f=ceil(abs(Q)/(n*1.0)+1e-15);
				e=max(e,f);
				P+=e*m;Q+=e*n;
			}
			else{
				e=floor((P*1.0)/m-1e-15);f=floor((Q*1.0)/n-1e-15);
				e=min(e,f);
				P-=e*m;Q-=e*n;
			}
			if(P<=0||Q<=0){cout<<"-1";return 0;}
			n=n1;m=m1;
		}
		else if(vy==0){
			if(y!=0&&y!=m){cout<<"-1";return 0;}
			if(vx>0)cout<<n;else cout<<0;cout<<" ";
			if(y==0){cout<<0<<" ";return 0;}
			else if(y==m){cout<<m<<" ";return 0;}
		}
		else {
			a=x+y;
			b=__gcd(m,n);if(abs(a)%b){cout<<"-1";return 0;}
			n1=n;m1=m;m=m/b;n=n/b;a=a/b;b=1;
			gcdExtended(n,m,&P,&Q);
		//	cout<<P<<" "<<Q<<"\n";
			c=a/b;P=P*c;Q*=c;//Q*=-1;
		//	cout<<P<<" "<<Q<<"\n";
			if(P<=0||Q>0){
				e=f=0;
				if(P<=0)e=ceil(abs(P)/(m*1.0)+1e-15);if(Q>0)f=ceil(abs(Q)/(n*1.0));
				e=max(e,f);P+=e*m;Q-=e*n;
			}
			else{
				e=floor((P*1.0)/m-1e-15);f=abs(Q)/n;e=min(e,f);
				P-=e*m;Q+=e*n;
			}
			if(P<=0||Q>0){cout<<"-1";return 0;}
			n=n1;m=m1;
		}
	}
	else if(vx==0){
	    //cout<<n<<" ";
		if(x==n){cout<<n;}else if(x==0)cout<<0;else {cout<<-1;return 0;}
		cout<<" ";
		if(vy>0)cout<<m;else cout<<0;return 0;
	}
	else {
		if(vy>0){
			a=x+y;
			b=__gcd(m,n);if(abs(a)%b){cout<<"-1";return 0;}
			n1=n;m1=m;m=m/b;n=n/b;a=a/b;b=1;
			gcdExtended(n,m,&P,&Q);
			c=a/b;P=P*c;Q*=c;

			if(P>0||Q<=0){
				e=f=0;
				if(P>0)e=ceil(abs(P)/(m*1.0));
				if(Q<=0)f=ceil(abs(Q)/(n*1.0)+1e-15);
				e=max(e,f);
				P-=e*m;Q+=e*n;
			}
			else{
				e=(-1*P)/m;f=floor((Q*1.0)/n-1e-15);e=min(e,f);//e=max(e,0LL);
				P+=e*m;Q-=e*n;
			}
			if(P>0||Q<0){cout<<"-1";return 0;}
			n=n1;m=m1;
			//cout<<P<<" "<<Q<<" ";
		}
		else if(vy==0){
			if(y!=0&&y!=m){cout<<"-1";return 0;}
			if(vx>0)cout<<n;else cout<<0;cout<<" ";
			if(y==0){cout<<0<<" ";return 0;}
			else if(y==m){cout<<m<<" ";return 0;}
		}
		else{
			a=x-y;
			b=__gcd(m,n);if(abs(a)%b){cout<<"-1";return 0;}
			n1=n;m1=m;m=m/b;n=n/b;a=a/b;b=1;
			gcdExtended(n,m,&P,&Q);
			c=a/b;P=P*c;Q*=c;Q*=-1;
			if(P>0||Q>0){
				e=f=0;
				if(P>0)e=ceil(abs(P)/(m*1.0));if(Q>0)f=ceil(Q/(n*1.0));
				e=max(e,f);P-=e*m;Q-=e*n;
			}
			else{
				e=(-1*P)/m;f=(-1*Q)/n;e=min(e,f);
				P+=e*m;Q+=e*n;
			}
			if(P>0||Q>0){cout<<"-1";return 0;}
			n=n1;m=m1;
		}
	}
	P=abs(P);Q=abs(Q);
	//cout<<P<<" "<<Q<<" ";
	if(P&1)cout<<n;else cout<<0;cout<<" ";
	if(Q&1)cout<<m;else cout<<0;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll long long
ll w,h;
ll quickmod(ll a,ll b){
	ll ans = 1;
	while(b){
		if(b%2){
			ans *= a;
			ans %= mod;
			b--;
		}
		b /= 2;
		a = a*a;
		a %= mod;
	}
	return ans;
}
int main(){
	scanf("%lld%lld",&w,&h);
	printf("%lld\n",quickmod(2,w+h));
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int n, m;
vector<vector<int> > a, b;
vector<bool> vis, dt;       // visited, don't take

void reset_vals()
{
    vis.clear();
    vis.assign(n, false);
    dt.clear();
    dt.assign(n, false);
}

void reset()
{
    a.clear();
    a.resize(n);
    b.clear();
    b.resize(n);
}

void read()
{
    cin>>n;
    reset();
    int i, x, y;

    cin>>m;
    for(i = 0;i < m;i++)
    {
        cin>>x>>y;
        x--, y--;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    cin>>m;
    for(i = 0;i < m;i++)
    {
        cin>>x>>y;
        x--, y--;
        b[x].push_back(y);
        b[y].push_back(x);
    }
}

bool dfs(int u)
{
    bool flag = true;
    vis[u] = true;

    for(int v : b[u])
        dt[v] = true;

    for(int v : a[u])
    {
        if(dt[v])
            return false;
        if(!vis[v] && !dt[v])
            flag &= dfs(v);
    }

    return flag;
}

void solve()
{
    int i, u, val, ans = 0;
    for(i = 0;i < n;i++)
    {
        reset_vals();
        if(!dfs(i))
            continue;

        val = 0;
        for(u = 0;u < n;u++)
        {
            if(vis[u])
                val++;
        }
        ans = max(ans, val);
    }

    cout<<ans<<"\n";
}

int main()
{
    read();
    solve();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const LL MOD = 1000000007;

LL cifang(LL a, LL n)
{
	LL ret = 1;
	while (n)
	{
		if (n % 2 == 1)
			ret = ret * a % MOD;
		a = a * a % MOD;
		n = n / 2;
	}
	return ret;
}

int main ()
{
	//freopen("input.txt","r",stdin);
	LL n;
	cin >> n;
	if (n == 0)
	{
		printf ("1\n");
		return 0;
	}
	LL t1 = cifang(4, n - 1) * 2 % MOD;
	LL t2 = cifang(2, n - 1);
	cout << (t1 + t2) % MOD << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,y,ans=0;
    cin>>n>>x>>y;
    for(int i=1;i<=x+y;i++)
    {
        if((x/i)+(y/i)>=n && (x/i)>0 && (y/i)>0)ans=i;
        else break;
    }
    cout<<ans;
}


#include <iostream>
int main(){std::cout<<"25\n";return 0;}
//2741


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(x) (int) ((x).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) static_cast<void>(0)
#endif

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using uint = unsigned int;
using vi = vector<int>;
using pii = pair<int, int>;

#define FNAME ""

// 1..k^2+1
ll gett(ll n, ll k) {
	if (n == 0)
		return k * (k + 1) / 2;
	ll num = gett(n / k, k);
	ll t = n % k;
	ll i = (num - 1) / k;
	ll j = (num - 1) % k;
	ll res = k * (k + 1) / 2 - t;
	if (t > i)
		res += k;
	if (t == i)
		res += k - j;
	return res;
}

ll solve(ll n, ll k) {
	ll x = k * k + 1;
	ll ind = (n - 1) / x;
	ll num = gett(ind, k);
	ll rem = (n - 1) % x + 1;
	if (rem == num) {
		ll t = ind % k;
		ll i = ind / k;
		return k * (k + 1) * i + (t + 1) * (k + 1);
	}
	if (rem >= num)
		rem--;
	return k * (k + 1) * ind + (rem - 1) / k * (k + 1) + (rem - 1) % k + 1;
}

int main() {
#ifdef LOCAL
	freopen(FNAME".in", "r", stdin);
	freopen(FNAME".out", "w", stdout);
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	int tn;
	cin >> tn;
	forn (tt, tn) {
		ll n, k;
		cin >> n >> k;
		cout << solve(n, k) << "\n";
	}

	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define LL long long

int c[66];
void init(int x)
{
    memset(c,0,sizeof(c));
    int k=(x/50)%475;
    int t=25;
    while(t--)
    {
        k=(k*96+42)%475;
        c[t]=k+26;
    }
}
int main()
{
    int p,x,y;
    while(~scanf("%d%d%d",&p,&x,&y))
    {
        int k=x-y;
        k=(k/50)*50;
        int re=x-(k+50);
        int flag=1;
        while(flag)
        {
            re+=50;
            init(re);
            for(int i=0;i<25;i++)
            {
                if(c[i]==p)
                {
                    flag=0;
                    break;
                }
            }
        }
        if(re<x)
        {
            printf("0\n");
        }
        else
        {
            printf("%d\n",(re+50-x)/100);
        }
    }
    return 0;
}


#pragma comment(linker, "/STACK:65777216")

#include <algorithm>
#include <iostream>
#include <string>
#include<sstream>
#include<string.h>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include<stack>
#include <set>
#include <map>
#include<ctime>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ull;

#define FOR(i,a,b) for (int i(a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define SORT(v) sort((v).begin(),(v).end())
#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define CL(a,b) memset(a,b,sizeof(a))
#define pb push_back

const int mod = 1000000009;
int n,m;
vector<string> v;

string D = "ACGT";
map<ll,int> c[1001];

int R1[11][11][11];
int next(int pos,int len,int next){
	if(R1[pos][len][next]!=-1) return R1[pos][len][next];
	string s = v[pos].substr(0, len);
	s += D[next];
	while(v[pos].substr(0, s.size()) != s)
		s.erase(s.begin());
	return R1[pos][len][next]=s.size();
}
int R2[11];
int pref(int pos){
	if(R2[pos]!=-1) return R2[pos];
	string s = v[pos];
	s.erase(s.begin());
	while(v[pos].substr(0, s.size()) != s)
		s.erase(s.begin());
	return R2[pos]=s.size();
}

int nv[11];

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

	CL(R2,-1);
	CL(R1,-1);

	cin>>n>>m;
	REP(i,m){
		string s;
		cin>>s;
		v.pb(s);
	}
	UN(v);
	m=v.size();
	vi t(v.size()+1);
	t[t.size()-1] = (1<<9)-1;
	c[0][(1<<9)-1]=1;
	for(int i=0;i<n;i++){
		//cout<<c[i].size()<<endl;
		for(map<ll,int>::iterator it = c[i].begin();it!=c[i].end();it++){
			ll x = it->first;
			int val = it->second;
			int mask = x & 1023;//t.back();
			x >>= 10;
			t.clear();
			REP(rr,v.size()) {
				t.pb(x&15);
				x>>=4;
			}
			reverse(t.begin(),t.end());

			REP(j,4){
				int nmask = mask<<1;
				ll ww = 0;
				int mx = 0;
				REP(k,m){
					nv[k] = next(k,t[k],j);
					if(nv[k] == v[k].size()){
						nmask |= ((1<<nv[k])-1);
						nv[k] = pref(k);
					}
					ww = (ww <<4) + nv[k];
					mx = max(mx, nv[k]);
				}
				if(!(nmask&(1<<9))) continue;

				int pos = 0;
				while(nmask & (1<<pos)) pos++;
				if(pos<9 && pos>=mx) continue;

				ww = (ww<<10) + (nmask^(1<<9));
				int q = c[i+1][ww] + val;
				if(q>=mod) q-=mod;
				c[i+1][ww] = q;

			}
		}
	}
	int res = 0;
	for(map<ll,int>::iterator it = c[n].begin();it!=c[n].end();it++){
		int mask = it->first & 1023;
		int val = it->second;

		if(mask == (1<<9) - 1){
			res += val;
			if(res>=mod) res-=mod;
		}
	}
	cout<<res<<endl;
	//cout<<clock()<<endl;
	return 0;
}


//==================================
//==========   WARNING   ===========
//==================================
//===   Contains too many bugs   ===
//==================================

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <queue>
#include <iomanip>

using namespace std;

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

#define double long double

const ll mod7 = 1000000007;

#define NAME "string"

int gcd(int a,int b)
{
    while(b)
    {
        a%=b;
        swap(a,b);
    }
    return a;
}

int main()
{
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    //freopen(NAME".in","r",stdin); freopen(NAME".out","w",stdout);

    int k,a,b,v;
    cin >> k >> a >> b >> v;
    int z = (a+v-1)/v;
    int l = 1, r = 1000000,ans = 0;
    while(l<=r)
    {
        int m = (l+r)>>1;

        int use = m*(k-1);
        int used = m+min(use,b);

        if(z<=used)
        {
            ans = m;
            r = m - 1;
        }
        else
            l = m+1;
    }
    cout << ans;
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include <stdlib.h>
#include <iomanip>
#include <algorithm>
#include <limits.h>
#include <stack>
#include <cmath>
#include <math.h>
#include <array>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);
#define DEBUG_VIS(x) cerr<<"vis "<<x<<endl;
#define DEBUG_REACH cerr<<"reach here"<<endl;
#define DEBUG_SEQ(x) cerr<<x<<" ";
#define SET_ZERO(x) memset(x,0,sizeof(x));
#define SET_NEGONE(x) memset(x,-1,sizeof(x));
#define SET_INF(x) memset(x,127,sizeof(x));
#define SET_NEGINF(x) memset(x,128,sizeof(x));
#define IS_INF(x) x < 2100000000
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<double,double> pdd;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
const int maxn = 1e6 + 10;
template <class T> T mymin(const T a,const T b){return a < b ? a : b;}
template <class T> T mymax(const T a,const T b){return a > b ? a : b;}
int dfn[maxn],low[maxn],scc_cnt,dfs_clock,inst[maxn],bel[maxn];
struct edge{
    int u,v;
    edge(int a = 0,int b = 0):u(a),v(b){};
};
vector<edge> es;
vector<int> G[maxn],sccs[maxn];
stack<int> S;
int N,M;
bool isbridge[maxn<<2];
void tarjan(int u,int in_edge){
    dfn[u] = low[u] = ++dfs_clock;
    S.push(u);
    for(int nx : G[u]){
        int v = es[nx].v;
        if(!dfn[v]){
            tarjan(v,nx);
            low[u] = min(low[u],low[v]);
            if(low[v] > dfn[u]) isbridge[nx] = 1;
        }
        else if(nx != (in_edge ^ 1)) low[u] = min(low[u],dfn[v]);
    }
    if(low[u] == dfn[u]){
        int v;
        scc_cnt++;
        do{
            v = S.top(); S.pop();
            sccs[scc_cnt].emplace_back(v);
            bel[v] = scc_cnt;
        }
        while(!S.empty() && u != v);
    }
}
int L[maxn],fa[maxn],dep[maxn],Z[maxn];
bool vis[maxn];
void bfs(){
    queue<int> q;
    q.push(1);
    vector<int> nodes;
    vis[1] = 1;
    while(!q.empty()){
        int u = q.front(); q.pop();
        nodes.emplace_back(u);
        for(int nx : G[u]){
            int v = es[nx].v;
            if(!vis[v]){
                vis[v] = 1;
                q.push(v);
                fa[v] = u;
            }
        }
    }
    for(auto it = nodes.rbegin(); it != nodes.rend(); it++){
        int u = *it;
        for(int nx : G[u]){
            int v = es[nx].v;
            if(fa[v] == u){
                dep[u] = max(dep[v] + 1,dep[u]);
                if(isbridge[nx]){
                    L[u] = max(L[u],1 + dep[v]);
                }
            }
        }
    }
}
void solve(int u,int par,int upval){
    L[u] = max(L[u],upval);
    auto &cycle = sccs[bel[u]];
    for(int it = 0; it < 2; it++){
        priority_queue<pii> q;
        for(int i = 0; i < 2 * cycle.size(); i++){
            int d = 2 * cycle.size() - i;
            while(!q.empty() && q.top().second - d > cycle.size() / 2) q.pop();
            if(!q.empty()) Z[cycle[i % cycle.size()]] = max(Z[cycle[i % cycle.size()]],q.top().first - d);
            q.push(make_pair(L[cycle[i % cycle.size()]] + d,d));
        }
        reverse(cycle.begin(),cycle.end());
    }
    for(auto u : cycle){
        int mx1,mx2;
        mx1 = mx2 = 0;
        for(int nx : G[u]){
            int v = es[nx].v;
            if(v == par || !isbridge[nx]) continue;
            if(mx2 < 1 + dep[v]){
                mx2 = 1 + dep[v];
                if(mx1 < mx2) swap(mx1,mx2);
            }
        }
        for(int nx : G[u]){
            int v = es[nx].v;
            if(v == par || !isbridge[nx]) continue;
            int pssval = max(upval,Z[u]);
            if(mx1 == 1 + dep[v]) pssval = max(pssval,mx2);
            else pssval = max(pssval,mx1);
            solve(v,u,pssval + 1);
        }
    }
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("data.in","r",stdin);
    #endif
    FAST_IO
    cin>>N>>M;
    for(int i = 1; i <= M; i++){
        int u,v;
        cin>>u>>v;
        es.emplace_back(edge(u,v));
        es.emplace_back(edge(v,u));
        G[u].emplace_back(es.size() - 2);
        G[v].emplace_back(es.size() - 1);
    }
    for(int i = 1; i <= N; i++) if(!dfn[i]) tarjan(i,0);
    bfs();
    solve(1,0,0);
    for(int i = 1; i <= N; i++) cout<<max(L[i],Z[i])<<" ";
    cout<<endl;
    return 0;
}


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

typedef long long ll;
ll mod = 1e9 + 7;
int dim;

vector <vector<ll> > Mul(vector < vector<ll> > a, vector<vector<ll> > b) {
    vector<vector<ll> > c;
    c.resize(dim + 1, vector<ll>(dim + 1 ,0));
    for(int i = 0; i <= dim; i++) {
        for(int j = 0; j <= dim; j++) {
            for(int k = 0; k <= dim; k++) {
                c[i][j] += a[i][k] * b[k][j];
                c[i][j] %= mod;
            }
        }
    }
    return c;
}

vector < vector<ll> > base;

vector <vector<ll>> f(ll k) {
    if (k == 1) return base;
    if (k&1) {
        return Mul(f(k-1),base);
    }
    vector <vector<ll>> res = f(k/2);
    return Mul(res,res);
}

ll bm(ll b, ll p) {
    if (p == 0) return 1;
    ll t = bm(b, p/2);
    t = (t*t)%mod;
    if (p&1) return (t*b)%mod;
    return t;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector <int> a(n,0);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] == 0) dim++;
    }
    ll xx = 0;
    for(int i = 0; i < dim; i++) {
        xx += (a[i] == 0);
    }
    if (dim == 0 or dim == n) {
        cout << 1 << endl;
        return 0;
    }
    base.resize(dim + 1, vector<ll>(dim + 1 ,0));

    for(ll z = 0; z <= dim; z++) {
        ll lftZ = z-1, lftO = dim-lftZ, rgtZ = dim-lftZ, rgtO = (n-dim)-rgtZ;
        /// from z-1 to z
        if (lftZ >= 0 && lftO >= 0 && rgtZ >= 0 && rgtO >= 0) {
            base[z][z-1] = (lftO * rgtZ)%mod;
        }
        /// from z+1 to z
        lftZ = z+1, lftO = dim-lftZ, rgtZ = dim-lftZ, rgtO = (n-dim)-rgtZ;
        if (lftZ >= 0 && lftO >= 0 && rgtZ >= 0 && rgtO >= 0) {
            base[z][z+1] = (lftZ * rgtO)%mod;
        }
        /// from z to z
        lftZ = z, lftO = dim-lftZ, rgtZ = dim-lftZ, rgtO = (n-dim)-rgtZ;
        if (lftZ >= 0 && lftO >= 0 && rgtZ >= 0 && rgtO >= 0) {
            base[z][z] = lftZ*lftO + rgtZ*rgtO + (dim*(dim-1))/2 + ((n-dim)*(n-dim-1))/2;
        }
    }
    vector <vector<ll>> res = f(k);
    ll ans = res[dim][xx];
    ans %= mod;
    if (ans < 0) ans+=mod;
    ll down = 1ll*n*(n-1)/2;
    down = bm(down,mod-2);
    down = bm(down, k);
    ans *= down;
    ans %= mod;
    if (ans < 0) ans += mod;
    cout << ans ;
}