#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define popcount(v) __builtin_popcount(v)
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll 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 updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

namespace internal {
constexpr long long safe_mod(long long x, long long m) {x %= m;if (x < 0) x += m;return x;}
struct barrett {
    unsigned int _m;
    unsigned long long im;
    explicit barrett(unsigned int m) : _m(m), im((unsigned long long)(-1) / m + 1) {}
    unsigned int umod() const { return _m; }
    unsigned int mul(unsigned int a, unsigned int b) const {
        unsigned long long z = a;
        z *= b;
#ifdef _MSC_VER
        unsigned long long x;
        _umul128(z, im, &x);
#else
        unsigned long long x =
            (unsigned long long)(((unsigned long long)(z)*im));
#endif
        unsigned int v = (unsigned int)(z - x * _m);
        if (_m <= v) v += _m;
        return v;
    }
};
constexpr long long pow_mod_constexpr(long long x, long long n, int m) {
    if (m == 1) return 0;
    unsigned int _m = (unsigned int)(m);
    unsigned long long r = 1;
    unsigned long long y = safe_mod(x, m);
    while (n) {
        if (n & 1) r = (r * y) % _m;
        y = (y * y) % _m;
        n >>= 1;
    }
    return r;
}
constexpr bool is_prime_constexpr(int n) {
    if (n <= 1) return false;
    if (n == 2 || n == 7 || n == 61) return true;
    if (n % 2 == 0) return false;
    long long d = n - 1;
    while (d % 2 == 0) d /= 2;
    constexpr long long bases[3] = {2, 7, 61};
    for (long long a : bases) {
        long long t = d;
        long long y = pow_mod_constexpr(a, t, n);
        while (t != n - 1 && y != 1 && y != n - 1) {y = y * y % n;t <<= 1;}
        if (y != n - 1 && t % 2 == 0) {return false;}
    }
    return true;
}
template <int n> constexpr bool is_prime = is_prime_constexpr(n);
constexpr std::pair<long long, long long> inv_gcd(long long a, long long b) {
    a = safe_mod(a, b);
    if (a == 0) return {b, 0};
    long long s = b, t = a;
    long long m0 = 0, m1 = 1;
    while (t) {long long u = s / t;s -= t * u;m0 -= m1 * u;auto tmp = s;s = t;t = tmp;tmp = m0;m0 = m1;m1 = tmp;}
    if (m0 < 0) m0 += b / s;
    return {s, m0};
}
constexpr int primitive_root_constexpr(int m) {
    if (m == 2) return 1;
    if (m == 167772161) return 3;
    if (m == 469762049) return 3;
    if (m == 754974721) return 11;
    if (m == 998244353) return 3;
    int divs[20] = {};
    divs[0] = 2;
    int cnt = 1;
    int x = (m - 1) / 2;
    while (x % 2 == 0) x /= 2;
    for (int i = 3; (long long)(i)*i <= x; i += 2) {
        if (x % i == 0) {divs[cnt++] = i;while (x % i == 0) {x /= i;}}
    }
    if (x > 1) {divs[cnt++] = x;}
    for (int g = 2;; g++) {
        bool ok = true;
        for (int i = 0; i < cnt; i++) {
            if (pow_mod_constexpr(g, (m - 1) / divs[i], m) == 1) {ok = false;break;}
        }
        if (ok) return g;
    }
}
template <int m> constexpr int primitive_root = primitive_root_constexpr(m);
unsigned long long floor_sum_unsigned(unsigned long long n,unsigned long long m,unsigned long long a,unsigned long long b) {
    unsigned long long ans = 0;
    while (true) {
        if (a >= m) {ans += n * (n - 1) / 2 * (a / m);a %= m;}
        if (b >= m) {ans += n * (b / m);b %= m;}
        unsigned long long y_max = a * n + b;
        if (y_max < m) break;
        n = (unsigned long long)(y_max / m);
        b = (unsigned long long)(y_max % m);
        std::swap(m, a);
    }
    return ans;
}
template <class T> using is_integral = typename std::is_integral<T>;
template <class T>
using is_signed_int =
    typename std::conditional<is_integral<T>::value && std::is_signed<T>::value,
                              std::true_type,
                              std::false_type>::type;
template <class T>
using is_unsigned_int =
    typename std::conditional<is_integral<T>::value &&
                                  std::is_unsigned<T>::value,
                              std::true_type,
                              std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<is_signed_int<T>::value,
                                              std::make_unsigned<T>,
                                              std::common_type<T>>::type;
template <class T> using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;
template <class T> using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;
template <class T> using to_unsigned_t = typename to_unsigned<T>::type;
struct modint_base {};
struct static_modint_base : modint_base {};
template <class T> using is_modint = std::is_base_of<modint_base, T>;
template <class T> using is_modint_t = std::enable_if_t<is_modint<T>::value>;
}  // namespace internal
template <int m, std::enable_if_t<(1 <= m)>* = nullptr>
struct static_modint : internal::static_modint_base {
    using mint = static_modint;
  public:
    static constexpr int mod() { return m; }
    static mint raw(int v) {mint x;x._v = v;return x;}
    static_modint() : _v(0) {}
    template <class T, internal::is_signed_int_t<T>* = nullptr>
    static_modint(T v) {
        long long x = (long long)(v % (long long)(umod()));
        if (x < 0) x += umod();_v = (unsigned int)(x);
    }
    template <class T, internal::is_unsigned_int_t<T>* = nullptr>
    static_modint(T v) {_v = (unsigned int)(v % umod());}
    unsigned int val() const { return _v; }
    mint& operator++() {_v++;if (_v == umod()) _v = 0;return *this;}
    mint& operator--() {if (_v == 0) _v = umod();_v--;return *this;}
    mint operator++(int) {mint result = *this;++*this;return result;}
    mint operator--(int) {mint result = *this;--*this;return result;}
    mint& operator+=(const mint& rhs) {_v += rhs._v;if (_v >= umod()) _v -= umod();return *this;}
    mint& operator-=(const mint& rhs) {_v -= rhs._v;if (_v >= umod()) _v += umod();return *this;}
    mint& operator*=(const mint& rhs) {unsigned long long z = _v;z *= rhs._v;_v = (unsigned int)(z % umod());return *this;}
    mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }
    mint operator+() const { return *this; }
    mint operator-() const { return mint() - *this; }
    mint pow(long long n) const {assert(0 <= n);mint x = *this, r = 1;while (n) {if (n & 1) r *= x;x *= x;n >>= 1;}return r;}
    mint inv() const {if (prime) {assert(_v);return pow(umod() - 2);} else {auto eg = internal::inv_gcd(_v, m);assert(eg.first == 1);return eg.second;}}
    friend mint operator+(const mint& lhs, const mint& rhs) {return mint(lhs) += rhs;}
    friend mint operator-(const mint& lhs, const mint& rhs) {return mint(lhs) -= rhs;}
    friend mint operator*(const mint& lhs, const mint& rhs) {return mint(lhs) *= rhs;}
    friend mint operator/(const mint& lhs, const mint& rhs) {return mint(lhs) /= rhs;}
    friend bool operator==(const mint& lhs, const mint& rhs) {return lhs._v == rhs._v;}
    friend bool operator!=(const mint& lhs, const mint& rhs) {return lhs._v != rhs._v;}
    //自分で加えたもの
    friend istream& operator>>(istream& os,mint& rhs) noexcept {
        long long v;
        rhs = mint{(os >> v, v)};
        return os;
    }
    friend constexpr ostream& operator << (ostream &os, const mint& rhs) noexcept {
        return os << rhs._v;
    }
  private:
    unsigned int _v;
    static constexpr unsigned int umod() { return m; }
    static constexpr bool prime = internal::is_prime<m>;
};
using mint=static_modint<1000000007>;
using mint2=static_modint<998244353>;

template <class S, S (*op)(S, S), S (*e)()> struct segtree {
  public:
    segtree() : segtree(0) {}
    segtree(int n) : segtree(std::vector<S>(n, e())) {}
    segtree(const std::vector<S>& v) : _n(int(v.size())) {
        log = ceil_pow2(_n);
        size = 1 << log;
        d = std::vector<S>(2 * size, e());
        for (int i = 0; i < _n; i++) d[size + i] = v[i];
        for (int i = size - 1; i >= 1; i--) {
            update(i);
        }
    }

    void set(int p, S x) {
        assert(0 <= p && p < _n);
        p += size;
        d[p] = x;
        for (int i = 1; i <= log; i++) update(p >> i);
    }

    S get(int p) {
        assert(0 <= p && p < _n);
        return d[p + size];
    }

    S prod(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        S sml = e(), smr = e();
        l += size;
        r += size;

        while (l < r) {
            if (l & 1) sml = op(sml, d[l++]);
            if (r & 1) smr = op(d[--r], smr);
            l >>= 1;
            r >>= 1;
        }
        return op(sml, smr);
    }

    S all_prod() { return d[1]; }

    template <bool (*f)(S)> int max_right(int l) {
        return max_right(l, [](S x) { return f(x); });
    }
    template <class F> int max_right(int l, F f) {
        assert(0 <= l && l <= _n);
        assert(f(e()));
        if (l == _n) return _n;
        l += size;
        S sm = e();
        do {
            while (l % 2 == 0) l >>= 1;
            if (!f(op(sm, d[l]))) {
                while (l < size) {
                    l = (2 * l);
                    if (f(op(sm, d[l]))) {
                        sm = op(sm, d[l]);
                        l++;
                    }
                }
                return l - size;
            }
            sm = op(sm, d[l]);
            l++;
        } while ((l & -l) != l);
        return _n;
    }

    template <bool (*f)(S)> int min_left(int r) {
        return min_left(r, [](S x) { return f(x); });
    }
    template <class F> int min_left(int r, F f) {
        assert(0 <= r && r <= _n);
        assert(f(e()));
        if (r == 0) return 0;
        r += size;
        S sm = e();
        do {
            r--;
            while (r > 1 && (r % 2)) r >>= 1;
            if (!f(op(d[r], sm))) {
                while (r < size) {
                    r = (2 * r + 1);
                    if (f(op(d[r], sm))) {
                        sm = op(d[r], sm);
                        r--;
                    }
                }
                return r + 1 - size;
            }
            sm = op(d[r], sm);
        } while ((r & -r) != r);
        return 0;
    }

  private:
    int _n, size, log;
    std::vector<S> d;
    int ceil_pow2(int n) {
        int x = 0;
        while ((1U << x) < (unsigned int)(n)) x++;
        return x;
    }
    void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
};

int modv;
ll op(ll a,ll b){return (a+b)%modv;}
ll e(){return 0;}

int main(){
    INT(n);
    in(modv);
    segtree<ll,op,e> seg(n+1);
    seg.set(1,1);
    ll v,v2,nxt,l,r,mid;
    for(int i=2;i<=n;i++){
        v=0;
        nxt=min(10000,n+1);
        for(j=2;j<nxt;j++){
            v+=seg.get(i/j);
            v%=modv;
        }
        while(nxt<i+1){
            v2=i/nxt;
            l=nxt,r=i+1;
            while(l<r){
                mid=(l+r)/2;
                if((i/mid)>=v2)l=mid+1;
                else r=mid;
            }
            v+=((l-nxt)%modv)*seg.get(v2);
            v%=modv;
            nxt=l;
        }
        v+=seg.prod(0,i);
        v%=modv;
        seg.set(i,v);
    }
    out(seg.get(n));
}


#include <bits/stdc++.h>
using namespace std ;
#define ll long long
const int MAXN=6;
const int MAXP=15625;
int n,m,a[MAXN+3],b[MAXN+3],c[MAXN+3][MAXN+3];
ll dp[MAXN+3][MAXP+5];
int rid[MAXP+5],id[1<<18];
int idnum=0;
void dfs(int x,int cur){
	if(x==n+1){rid[++idnum]=cur;id[cur]=idnum;return;}
	for(int i=0;i<=a[x];i++) dfs(x+1,cur+(i<<(3*(x-1))));
}
void dfs2(int x,int t,int msk,int lft,ll val){
	if(!lft||x==n+1){chkmin(dp[t][id[msk]],val);return;}
	for(int i=0;i<=min(a[x]-(msk>>(3*(x-1))&7),lft);i++){
		dfs2(x+1,t,msk+(i<<(3*(x-1))),lft-i,val+(i>0)*c[x][t]);
	}
}
int main(){
	scanf("%d%d",&n,&m);int sa=0,sb=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sa+=a[i];
	for(int i=1;i<=m;i++) scanf("%d",&b[i]),sb+=b[i];
	if(sa>sb) return puts("-1"),0;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&c[i][j]);
	dfs(1,0);memset(dp,63,sizeof(dp));dp[0][id[0]]=0;
	for(int i=0;i<m;i++){
		vector<int> pos;
		for(int l=1;l<=idnum;l++){
			if(dp[i][l]>=0x3f3f3f3f3f3f3f3fll) continue;
			dfs2(1,i+1,rid[l],b[i+1],dp[i][l]);
		}
	} int lst=0;for(int i=1;i<=n;i++) lst|=(a[i]<<(3*(i-1)));
	if(dp[m][id[lst]]<0x3f3f3f3f3f3f3f3fll) printf("%lld\n",dp[m][id[lst]]);
	else puts("-1");
	return 0;
}


#include <assert.h>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
const int INF = 1e9;
int n, m;
int chests[10];
int keys[10];
int costs[10][10];
int ans = INF;
struct state {
    vector<int> a;
    int i;
    int j;
    int r;

    bool operator==(const state& other)
    {
        return i == other.i && j == other.j && a == other.a;
    };
};
int convert(state tmp)
{
    int res = 0;
    for (auto& e : tmp.a) {
        assert(e < 7);
        res = res * 7 + e;
    }
    assert(tmp.r < 7);
    res = res * 7 + tmp.j;
    assert(tmp.i < 7);
    res = res * 7 + tmp.r;
    assert(tmp.j < 7);
    res = res * 7 + tmp.i;
    return res;
}
state convertBack(int index)
{
    state res;
    res.i = index % 7;
    index /= 7;
    res.r = index % 7;
    index /= 7;
    res.j = index % 7;
    index /= 7;
    for (int i = 0; i < n; ++i) {
        res.a.push_back(index % 7);
        index /= 7;
    }
    std::reverse(res.a.begin(), res.a.end());
    return res;
}
int dp[40353607] = { 0 };
int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> chests[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> keys[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> costs[i][j];
        }
    }
    memset(dp, 0xff, sizeof(dp));
    dp[0] = 0;
    for (int i = 0; i < 40353607; ++i) {
        if (dp[i] < 0)
            continue;
        state curState = convertBack(i);
        if (curState.j == m) {
            continue;
        }
        /*
        cout << "fuck ";
        for (auto cur : curState.a)
            cout << cur << ' ';
        cout << endl;
        cout << curState.i << ' ' << curState.j << ' ' << curState.r << endl;
        */
        for (int flow = 0; flow < 5; ++flow) {
            auto nextState = curState;
            if (flow + curState.a[curState.i] > chests[curState.i] || flow + curState.r > keys[curState.j]) {
                continue;
            }
            int added = flow == 0 ? 0 : costs[curState.i][curState.j];
            nextState.r = flow + curState.r;
            nextState.a[curState.i] += flow;
            nextState.i++;
            if (nextState.i == n) {
                nextState.i = 0;
                nextState.j++;
                nextState.r = 0;
            }
            auto index = convert(nextState);
            dp[index] = (dp[index] == -1 || dp[index] > dp[i] + added) ? dp[i] + added : dp[index];
            auto isFinal = [&](state s) -> bool {
                for (int i = 0; i < s.a.size(); ++i) {
                    if (s.a[i] != chests[i]) {
                        return false;
                    }
                }
                return true;
            };
            if (isFinal(nextState)) {
                ans = min(ans, dp[index]);
            }
        }
    }
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long;
typedef long long ll;
const int N=55;
ll first1;
int n,cnt,ed;
char ss[N];
int s[N];
unordered_map<ll,int> ha;
void work(int a[],int lmt)
{
    int deg=0;
    for(int i=lmt;i>=0;i--)
        if(a[i]){deg=i; break;}
    if(deg<ed) return;
    else
    {
        for(int i=0;i<=ed;i++)
            a[i+deg-ed]^=s[i];
        work(a,deg-1);
    }
}
inline int h(int a[])
{
    ll ans=0;
    for(int i=0;i<=ed;i++)
        ans=ans*2+a[i];
    return ans;
}
ll BSGS()
{
    int B=sqrt(1.0*(1ll<<ed))+1;
    int z[N],b[N<<1],c[N<<1];
    memset(z,0,sizeof z); z[0]=1;
    memset(b,0,sizeof b); b[0]=1;
    ha[h(z)]=0;
    for(int i=1;i<=B;i++)
    {
        for(int j=ed;j>=1;j--) z[j]=z[j-1];
        z[0]=0;
        work(z,ed);
        if(i!=B) ha[h(z)]=i;
    }
    for(int k=1;k<=B;k++)
    {
        memset(c,0,sizeof c);
        for(int i=0;i<=ed;i++)
        {
            if(!z[i]) continue;
            for(int j=0;j<=ed;j++)
                c[i+j]=c[i+j]^(z[i]*b[j]);
        }
        memcpy(b,c,sizeof c);
        work(b,ed<<1);
        int t=h(b);
        if(ha.count(t)) return k*B-ha[t];
    }
    return -1;
}
signed main()
{
    scanf("%s",ss+1);
    int n=strlen(ss+1);
    for(int i=1;i<=n;i++)
    {
        if(!(ss[i]-'0')) continue;
        cnt++;
        if(!first1) first1=i;
    }
    if(!cnt) {puts("-1"); return 0;}
    else if(cnt==1) {printf("%lld %lld\n",first1,first1+1); return 0;}
    for(int i=first1;i<=n;i++)
        if(ss[i]-'0')
            s[i-first1]=1,ed=max(ed,(int)(i-first1));
    ll res=BSGS();
    if(res==-1) puts("-1");
    else printf("%lld %lld\n",first1,first1+res);
    return 0;
}


//#define fi first
//#define sc second
//#define mp(x,y) make_pair(x,y)
//#define pa pair<ll,ll>
#include<bits/stdc++.h>
#define ll long long
#define LL __int128
#define in(x) x=read()
using namespace std;
ll hi;
inline LL read()
{
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(ch^48);
		if(x == 0 && ch == '0')hi++;
		ch=getchar();
	}
    return x*f;
}
ll www,M;
ll mod(ll x)
{
	if(x & (1ll<<www))x^=M;
	return x;
}
ll mul(ll x,ll y)
{
	ll ans=0;
	for(int s=0;;s++,y=mod(y<<1))
	{
		if((1ll<<s) > x)return ans;
		if((1ll<<s) & x)ans =y^ans;
	}
}
map<ll,ll>mp;
int main()
{
	in(M);
	while(M%2==0)M/=2;
	www=__lg(M);
	if(M == 0)
	{
		puts("-1");
		return 0;
	}
	printf("%lld ",hi+1);
	mp[1]=1;
	ll nw = 1;
	for(int s=2;s<262144;s++)
	{
		nw = mod(nw<<1);
		mp[nw] = s;
//		if(s == 33911 || s==33769)
//		cout<<s<<"->"<<nw<<endl;
	}
	nw=mod(nw<<1);
	ll fk=nw;
	for(int s=1;s<=262144;s++)
	{
		if(mp.count(fk) == 1)
		{
			cout<<hi+1+s*262144ll-mp[fk]-(s-1)<<endl;
//			cerr<<s<<"->"<<mp[fk]<<endl;
			return 0;
		}
		fk = mul(fk,nw);
	}
	return 0;
}


//JAI SHREE RAM//

#include<bits/stdc++.h>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(int i = a; i < b; i++)
#define rep(i,a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define INF 1000000000000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define goog(tno) cout << "Case #" << tno <<": "
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define read(x) int x; cin >> x
#define pii pair<int,int>
#define piii pair<int,pii>
#define ff first
#define ss second
#define int long long
#define ull unsigned long long
#define p4i pair<pii, pii>
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
using namespace std;
map<pair<int, pair<int, pair<char, int>>>, int> dp;

int f(int idx, int lead, char x, int modulo, string s) {

	if (idx == s.size()) {
		if (modulo == 0) return 1;
		else return 0;
	}
	int ans = 0;
	if (dp.find({idx, {lead, {x, modulo}}}) != dp.end()) return dp[ {idx, {lead, {x, modulo}}}];;
	//if (dp[idx][lead][x - '0'][modulo] != -1) return dp[idx][lead][x - '0'][modulo];
	if (lead == 1 && s[idx] == '0') return 0;
	if (s[idx] >= '0' && s[idx] <= '9') {
		int modulo2 = (modulo * 10 + (s[idx] - '0')) % 25;
		ans += f(idx + 1, 0, x, modulo2, s);
	}
	else if (s[idx] == '_') {
		if (!lead)ans += f(idx + 1, 0, x, (modulo * 10) % 25, s);

		for (int i = 1; i < 10; i++) {
			ans += f(idx + 1, 0, x, (modulo * 10 + i) % 25, s);
		}

	}
	else {
		if (x == '#') {
			if (!lead)ans += f(idx + 1, 0, '0', (modulo * 10) % 25, s);

			for (int i = 1; i < 10; i++) {
				ans += f(idx + 1, 0, i + '0', (modulo * 10 + i) % 25, s);

			}
		}
		else {
			ans += f(idx + 1, 0, x, (modulo * 10 + (x - '0')) % 25, s);
		}

	}
	dp[ {idx, {lead, {x, modulo}}}] = ans;
	return ans;

}

void solve(int testcase)
{
	dp.clear();
	string s;
	cin >> s;
	if (s == "0" || s == '_' || s == 'X' ) {
		cout << 1;
		return;
	}
	int ans = f(0, 1, '#', 0, s);
	cout << ans;

}

signed main()
{

	int test = 1;

	for (int init = 1 ; init <= test ; init++)
	{
		solve(init);
	}

}


#include <iostream>
#include <stdlib.h>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <list>
#include <sstream>
#include <cctype>
#include <deque>
#include <queue>
#include <stack>
#include <limits>
#include <climits>
#include <numeric>
#include <cstdio>
#include <cstring>

#define Epsilon 0.00000000001f
#define ll long long int
#define ld long double
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i <= int(n); i++)
#define forn_reverse(i, n) for (int i = (int)n-1; i >= 0; i--)
using namespace std;

void printv(vector<int>& v){
    for(int j = 0;j< v.size();j++){
        cout << v[j] << " ";
    }
    cout << endl;
}

int tenthPower(int n){
    if(n == 0) return 0;
    int ans = 1;
    while(n--){
        ans *= 10;
    }
    return ans;
}
string s;
int n;
char a,b;

int count_(int r){
    int num = 0;
    for(int i = 1;i <= r;i++){
        char c = s[i];
        if(c == '_'){
            num++;
        }
    }
    if(r < 0){
        return 1;
    }
    int ans = tenthPower(num);
    if(s[0] == '_'){
        if(ans == 0) ans += 9;
        else ans *= 9;
    }
    if(ans > 0) return ans;
    else return 1;
}
int countx(int r){
    if(s[0] == 'x'){
        return 9;
    }
    for(int i = 1;i <= r;i++){
        if(s[i] == 'x'){
            return 10;
        }
    }
    return 1;
}

void caseXX(){
    if(n == 2){
        cout << 0 <<endl;
        endl;
    }
    int ans = count_(n-3);
    cout << ans << endl;
    return;
}

void case__(){
    if(n == 2) {
        cout << 3 <<endl;
        return;
    }
    int ans = 4;
    int ans_ = count_(n-3);
    int ansX = countx(n-3);
    cout << ans * ans_ * ansX<<endl;
    return;
}

void case_X(){
    if(n == 2){
        cout << 3 <<endl;return;
    }
    //x = 5
    int ans = count_(n-3) * 2;
    if(s[0] != 'X'){
        ans += count_(n-3) * 2;
    }
    cout << ans <<endl;
    return;
}
void caseX_(){
    if(n == 2) {
        cout <<3 <<endl;return;
    }
    int ans = 4;
    if(s[0] == 'X') ans = 3;
    ans *= count_(n-3);
    cout << ans <<endl;
}
void case5X(){
    if(s[n-2] == '5' || s[n-2] == '0' || s[n-2] == '7' || s[n-2] == '2'){
        if(s[0] == 'X' && (s[n-2] == '5' || s[n-2] == '0')){
            cout << 0 <<endl;
            return;
        }else{
            cout << count_(n-3)<<endl;
            return;
        }
    }else{
        cout << 0 <<endl;
        return;
    }
}
void caseX5(){
    if(s[n-1] == '0' || s[n-1] == '5'){
        if(s[n-1] == '5'){
            cout << count_(n-3) * 2 <<endl;
            return;
        }else{
            if(s[0] == 'X'){
                cout << count_(n-3) <<endl;
                return;
            }else{
                cout << count_(n-3) * 2 <<endl;
                return;
            }
        }
    }else{
        cout << 0 <<endl;
    }
}
void case5_(){
    if(s[n-2] == '5' || s[n-2] == '0' || s[n-2] == '7' || s[n-2] == '2'){
        int ans = 2;
        int ans_ = count_(n-3);
        int ansX = countx(n-3);
        cout << ans * ans_ * ansX<<endl;
    }else{
        cout << 0 <<endl;
    }
}
void case_5(){
    if(s[n-1] == '0' || s[n-1] == '5'){
        int ans = 2;
        if(n == 2 && s[n-1]== '0'){
            ans = 1;
        }
        int ans_ = count_(n-3);
        int ansX = countx(n-3);
        cout << ans * ans_ * ansX<<endl;
    }else{
        cout << 0 <<endl;
    }
}
void case55(){
    char a = s[n-2];
    char b = s[n-1];
    string ab = "";
    ab.push_back(a);ab.push_back(b);
    if(ab == "00" || ab=="25" || ab == "50" || ab == "75"){
        cout << count_(n-3) * countx(n-3) <<endl;
    }else{
        cout << 0 <<endl;
    }
}
void solve(){
    cin >> s;
    if(s.size() == 1){
        if(s[0] == '0' || s[0] == 'X' || s[0] == '_'){
            cout << 1 << endl;
            return;
        }else{
            cout << 0 << endl;
            return;
        }
    }
    if(s[0] == '0') {
        cout << 0 << endl;
        return;
    }
    n = (int)s.size();
    a = s[n-2];
    b = s[n-1];
    //XX
    if(a=='X' && b=='X'){
        caseXX();
    }
    //__
    if(a == '_' && b == '_'){
        case__();
    }
    //X_
    if(a == 'X' && b == '_'){
        caseX_();
    }
    //_X
    if(a == '_' && b == 'X'){
        case_X();
    }
    //X5
    if(a == 'X' && b!= 'X' && b!= '_'){
        caseX5();
    }
    //5X
    if(a != 'X' && a!= '_' && b == 'X'){
        case5X();
    }
    //_5
    if(a == '_' && b!= 'X' && b!= '_'){
        case_5();
    }
    //5_
    if(a != 'X' && a!= '_' && b == '_'){
        case5_();
    }
    //55
    if(a != 'X' && a!= '_' && b!= 'X' && b!= '_'){
        case55();
    }

}

int main() {
    cerr << "coding...\n";
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll MOD=1e9+7;
using namespace std;
ll N,M,K,R,C;
ll a,b,c,d;
vector <pair<ll,ll> > vec;
ll pangkat(ll x,ll y){
	if(y==0){
		return 1;
	}
	if(y==1){
		return x;
	}
	ll z=pangkat(x,y/2);
	if(y%2==0){
		return (z*z)%MOD;
	}
	else{
		return ((z*z)%MOD*x)%MOD;
	}
}
int main(){
	cin>>N>>M>>K>>R>>C;
	cin>>a>>b>>c>>d;
	ll x=2*R-abs(max(a+R-1,c+R-1)-min(a,c)+1);
	ll y=2*C-abs(max(b+C-1,d+C-1)-min(b,d)+1);
	if(x<=0||y<=0){
		cout<<pangkat(K,N*M-R*C)<<endl;
	}
	else{
		ll tempx=x;
		ll tempy=y;
		vec.push_back({R,C});
		ll offx=abs(a-c);
		ll offy=abs(b-d);
		while(tempx>0&&tempy>0){
			vec.push_back({tempx,tempy});
			tempx-=offx;
			tempy-=offy;
		}
		ll exp=N*M-2*vec[0].fi*vec[0].se+vec[1].fi*vec[1].se;
		for(int i=0;i<vec.size()-2;i++){
			exp+=vec[i].fi*vec[i].se-2*vec[i+1].fi*vec[i+1].se+vec[i+2].fi*vec[i+2].se;
		}
		ll s=vec.size();
		exp+=vec[s-2].fi*vec[s-2].se-2*vec[s-1].fi*vec[s-1].se;
		exp+=vec[s-1].fi*vec[s-1].se;
		cout<<pangkat(K,exp)<<endl;
	}
}


#include<iostream>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
ll xx,yy,x,y,rr,cc,n,m,k,c,r,xa,ya,xb,yb,p,ans;
ll posw(ll x){
	ll tt=1,t=k;
	while(x){
		if(x&1)tt=tt*t%MOD;
		x>>=1;
		t=t*t%MOD;
	//	cout<<tt<<"ALB"<<t<<"NNN"<<x<<endl;
	}
	return tt;
}
ll sz(ll a,ll b){
	if(a%b==0)return a/b;
	else return a/b+1;
}
int main(){
	scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&k,&r,&c);
	scanf("%I64d%I64d%I64d%I64d",&xa,&ya,&xb,&yb);
	if(xa>=xb&&ya>=yb){
	swap(xa,xb);swap(ya,yb);
	}
	if(xa==xb&&ya==yb){
		cout<<pow(n*m)<<endl;return 0;
	}
	if(xb>xa+r-1||yb>ya+c-1){
		ans=posw(n*m-r*c);
	}
	else{
		xx=abs(xa-xb);yy=abs(ya-yb);
		x=sz(r,xx)-1;y=sz(c,yy)-1;
		p=min(x,y);
		rr=r-p*xx;cc=c-p*yy;
		ans=2*(p-1)*xx*yy-rr*cc+(r-(p-1)*xx)*(c-(p-1)*yy);
	//	cout<<ans<<"CNM"<<endl;
		ans+=m*n-(r+xx)*(c+yy)+2*xx*yy;
	//	cout<<ans<<"YSS"<<k<<"IYSD"<<posw(ans)<<endl;
		ans=posw(ans);
	}
	cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define vc vector
#define s second
#define f first

#include "prettyprint.hpp"

using namespace std;

typedef pair <int, int> pii;
int n, m;
int t(int a){
    return a+n;
}
int mod=998244353;
vc< vc <int> > anz, suf, pref;

bool g (int a, int b){
    if (a<0 || b<0) return false;
    if (a >n || b >=m) return false;
    return true;
}

int h (int a, int b){
    if (a<0 || a>n) return 1;
    return 0;
}

int an(int a ,int b){
    return g(a, b)? anz[a][b] : h(a, b);
}

int su(int a ,int b){
    return g(a, b)? suf[a][b] : h(a, b);
}

int pre(int a ,int b){
    return g(a, b)? pref[a][b] : h(a, b);
}
int plu (int & a, int b){
    return a =(a+b)%mod;
}

int mult (int a, int b){
    return a*b % mod;
}

int calc_inst(int i, int j){
    int s1 = mult(mult(an(i, j), an(n-i+1, j-1)), su(n-i, m-j));

    int s2 = mult(mult(an(i, j), an(i+1, m-j-1)), pre(i, m-j+1));

    return plu(s1, s2);

}
int do_calc(){
    anz = suf = pref = vc <vc <int> > (n+1, vc <int > (m+1));

    vc <vc <int > > b (n+1, vc <int> (m)), c (n+1, vc <int> (m));

    anz[0][0] = 1;

    for (int i=1; i<=n; i++){
       anz[i][0] = anz[i-1][0];
        for (int j=1; j<m; j++){
            anz[i][j] = (anz[i][j-1]+anz[i-1][j])%mod;
        }
    }
    for (int i=1; i<=n; i++){
        for (int j=1; j<m; j++){
            b[i][j] = anz[i][j]*anz[n-i+1][j-1] % mod;
            suf[i][j] = (suf[i-1][j]+b[i][j])%mod;
        }

    }

    for (int i=1; i<n; i++){
        for (int k=m-1; k>=2; k--){
            c[i][k] = anz[n-i][k]*anz[n-i+1][m-k-1]%mod;
            pref[i][k]=(pref[i][k+1]+c[i][k])%mod;
        }

    }

    int ret = 0;
    for (int i=1; i<=n; i++){
        for (int j=1; j<m; j++){
            plu(ret, calc_inst(i, j));
        }
    }
    return ret;

}

void do_test(){

    cin >> n >> m;
    int res= do_calc();
    //a1 = very_balanced();
   // cout << res << "\n";
    //swap(n, m);
  //  a2 = very_balanced();
   // res1=do_calc();
    //assert(a1 == a2);
//a1 = (n-1)*(m-1);

    res = 2*res%mod;

   // cout << "res1 " << res1 << " " << res2 << " a " << a1 <<  " " << a2 << " " << endl;

    cout << res << "\n";

    //cout << a << endl;

}
signed main(){
    ios_base::sync_with_stdio(false);

    do_test();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const ll mod=998244353;
const ll N=5001;
int z;
int c[N][N];
int w[N/2][N/2];
int pw[N/2][N/2];
ll ans=0;
void solve(int n,int m,int k){//blue disconnected
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=m ;j++){
			ll r=c[i-1+m-j][m-j];
			ll l=c[i+j-1][j-1];
			w[i][j]=l*r%mod;
			pw[i][j]=(pw[i][j-1]+w[i][j])%mod;
			//cout << w[i][j] << ' ';
		}
	//	cout << endl;
	}
	for(int i=1; i<n ;i++){
		for(int j=1; j<m ;j++){
			ans+=1LL*w[i][j]*pw[n-i][m-j];
			if(k==1){
				ans-=1LL*w[i][j]*w[n-i][m-j];
			}
			ans=(ans%mod+mod)%mod;
		}
	}
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	;
	cin >> n >> m;z=n+m;
	c[0][0]=1;
	for(int i=1; i<=z ;i++){
		c[i][0]=1;
		for(int j=1; j<=i ;j++){
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
		}
	}
	solve(n,m,1);
	solve(m,n,0);
	ans=ans*2%mod;
	cout << ans << '\n';
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define per(i, a, b) for (int i = (a); i >= int(b); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define il inline
#define ct template<class type>
#define clr(a, n) memset((a), 0, sizeof((a[0]) * n))
#define cpy(a, b, n ) memcpy((b), (a), sizeof((a[0]) * ()n))

using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> pii;
ct il void cmax(type &x, type y) { x < y ? x = y:0; }
ct il void cmin(type &x, type y) { x > y ? x = y:0; }

const int maxn = 55; maxl == 2005; mod = 998244353;
il int& red(int &x) { return x += x >> 31 & mod; }

il int qpow(int a, int b) {
	int c = 1;
	for (; b; b >>= 1, a = ll(a) * a % mod) if (b & 1) c = ll(a) * c % mod;
	return c;
}

il int sx(int s, int x) {
	return s & 1 ? red(x = -x) : x;
}

int n, K, L, l[maxn], f[maxn][maxl], g[maxn][maxl], fac[maxl], fic[maxl];

void prework(int n) {
	fac[0] = 1;
	rep(i, 1, n) fac[i] = ll(i) * fac[i - 1] % mod;
	fic[n] = qpow(fac[n], mod - 2);
	per(i, n, 1) fic[i - 1] = ll(i) * fic[i] % mod;
}

int main() {
	prework(2e3);
	scanf("%d %d", &n, &K);
	rep(i, 1, n) {
		scanf("%d", &l[i]), L += l[i];
	}
	int iL = qpow(L, mod - 2);
	f[0][0] = 1;
	int mx = 0;
	rep(i, 1, n) {
		rep(j, 0, i - 1) rep(k, 0, mx) {
			g[j][k] = f[j][k];
		}
		rep(u, 1, l[i] / K) {
			int x = ll(l[i] - u * K) * iL % mod, y = qpow(x, u);
			int p = ll(y) * sx(u, fic[u]) % mod, q = ll(p) * u % mod * qpow(x, mod - 2) % mod;
			rep(j, 0, i - 1) rep(k, 0, mx) {
				red(g[j][k + u] += ll(p) * f[j][k] % mod - mod);
				red(g[j + 1][k + u] += ll(q) * f[j][k] % mod - mod);
			}
		}
		mx += l[i] / K;
		rep(j, 0, i) rep(k, 0, mx) {
			f[j][k] = g[j][k];
		}
	}
	int ans = 0;
	rep(j, 0, n) rep(k, 1, mx) if (k - j >= 0) {
		red(ans -= ll(f[j][k]) * fac[k - j] % mod * qpow(ll(k * K) * iL % mod, mod - 2 - (k - j)) % mod);
	}
	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long N=2200,mod=998244353;

long long ksm(long long a,long long x){
    long long tot=1;
    while(x){
        if(x & 1ll) tot=1ll*tot*a%mod;
        a=1ll*a*a%mod;
        x>>=1ll;
    }
    return tot;
}

long long mul[N],inv[N];
void init(long long lim){
    mul[0]=inv[0]=1;
    for(long long i=1;i<=lim;i++) mul[i]=1ll*mul[i-1]*i%mod;
    inv[lim]=ksm(mul[lim],mod-2);
    for(long long i=lim-1;i>=1;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
long long ID(long long x){
	if(x & 1ll) return mod-1;
	return 1;
}

long long n,k,ans;
long long a[N],S;
long long F[2][N][N],id;

int main(){
	init(N-5);
    cin>>n>>k;
    for(long long i=1;i<=n;i++) cin>>a[i],S+=a[i];
    F[0][0][0]=1;
	for(long long i=1;i<=n;i++){
		id^=1;
		memset(F[id],0,sizeof(F[id]));
		long long m=a[i];
		if(m==k) m--;
		for(long long t=0;t<=m/k;t++){
			long long val1=0,val2=0;
			val1=ID(t)*inv[t]%mod*ksm((m-t*k)*ksm(S,mod-2)%mod,t)%mod;
			if(t) val2=ID(t)*inv[t-1]%mod*ksm((m-t*k)*ksm(S,mod-2)%mod,t-1)%mod;

			for(long long p=0;p<=S;p++)
				for(long long q=0;q<=n;q++){
					if(p+t<=S) F[id][p+t][q]=(F[id][p+t][q]+F[id^1][p][q]*val1%mod)%mod;
					if(t && p+t-1<=S && q+1<=n) F[id][p+t-1][q+1]=(F[id][p+t-1][q+1]+F[id^1][p][q]*val2%mod)%mod;
				}

		}
//		cout<<i<<": \n";
//		for(long long p=0;p<=S;p++){
//			for(long long q=0;q<=n;q++){
//				cout<<F[i][p][q]<<" ";
//			}
//			cout<<endl;
//		}
	}
    for(long long p=0;p<=S;p++)
		for(long long q=0;q<=n;q++){
			long long P=p,Q=(S-(p+q)*k)*ksm(S,mod-2)%mod;
			ans=(ans+F[id][p][q]*mul[P]%mod*ksm(ksm((1+mod-Q)%mod,P+1),mod-2)%mod)%mod;
		}
	cout<<(mod-ans)%mod;
    return 0;
}


#include <iostream>
using namespace std;
ll fastp(ll a, ll b){
ll res=1;
while(b){
    if(b%2) res*=a;
    a*=a;
    b/=2;
}
return res;
}
int main(){
int t; cin>>t; while(t--){
unsigned ll n;
cin>>n;
    cout<<fastp(2,n)-1<<endl;

}

return 0;
}


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

int main() {

        int t;
        cin >> t;
        while(t--){
        	int n;
        	cin >> n;
            int ans = pow(2,n)-1;
            cout << ans << "\n"
        }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cout<<#x<<" = "<<x<<"\n";
#define int long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef pair<int, int> PII;
const int mod=1e9+7;

const int N=1e6+10;

int n;
int primes[N], cnt;
int phi[N];
bool st[N];

void get(int n){5
    5
    phi[1]=1;
    rep(i,2,n){
        if(!st[i]){
            primes[cnt++]=i;
            phi[i]=i-1;
        }
        for(int j=0;primes[j]<=n/i;j++){
            st[primes[j]*i]=1;
            if(i%primes[j]==0){
                phi[primes[j]*i]=primes[j]*phi[i];
                break;
            }
            phi[primes[j]*i]=(primes[j]-1)*phi[i];
        }
    }
}

int lcm(int x,int y){
    return x*y/__gcd(x,y);
}

void solve(){
    cin>>n;
    get(n);
    int ans=0;
    rep(i,1,n){ //gcd(a,b)
        for(int j=2*i;j<n;j+=i){ //a+b
            (ans+=phi[j/i]*lcm(n-j,i)%mod)%=mod;
        }
    }
    cout<<ans;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout<<setiosflags(ios::fixed)<<setprecision(10);
    // int _;cin>>_;while(_--)
    solve();
}


#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, ll>
#define st first
#define nd second
#define file "test"
using namespace std;
const long long INF = 1e18;
const long long N = 2e5 + 5;
const long long MOD = 1e9 + 7;
ll cnt[N];
ll n;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    #endif

    cin >> n;

    for (int i = 1; i <= n; i ++)
        cnt[i] = i - 1;
        for (int j = 2; j * j <= i; j ++) if (i % j == 0) {
            cnt[i] -= cnt[j];
            if (j * j != i) cnt[i] -= cnt[i / j];
        }

    ll ans = 0;
    for (int g = 1; g <= n; g ++)
        for (int x = g; x <= n; x += g)
            ans = (ans + (1ll * (n - x) * (g / __gcd(1ll * g, n - x)) % MOD * cnt[x / g])) % MOD;

    cout << ans % MOD << '\n';

    return 0;
}


 #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll int,ll int>
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll int gcd(ll int a,ll int b){if(!b)return a; return gcd(b, a % b);}
ll int lcm(ll int a,ll int b){ return (a*b)/gcd(a,b);}
string inc(string &s){  ll x = stoll(s);   x++;  return s = to_string(x);}

template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m;} return ans%m; }

int main(){
    IOS;
ll int tt=1;
  //cin>>tt;
for(ll int ii=1;ii<=tt;ii++){
  ll int n,m,k,ans=0,mod=1000000007;
  cin>>n>>k;
  m=pow(2ll,n,mod);

  if(k==1) cout<<n+1<<endl;
  else{
  for(ll int i=1;i<=min(n,k);i++){
      ans+=(modDivide(m,pow(2ll,i,mod),mod));
      // cout<<ans<<" ";
      ans%=mod;
  }

  cout<<ans+1<<endl;
  }
}
}


#include <bits/stdc++.h>
const int MAXN = 1e5 + 5, P = 1e9 + 7;
#define int long long
using namespace std;
int n, k;
LL fact[MAXN], inv[MAXN];
LL ksm(LL a, LL b = P - 2, LL p = P)
{
	LL s = 1 % p;
	for (; b; b >>= 1, a = a * a % p)
		if (b & 1) s = s * a % p;
	return s;
}
signed main()
{
	cin>>n>>k;
	k = min(n, k),fact[0] = 1;
	for (int i = 1; i <= n; ++i)
	    fact[i] = i * fact[i - 1] % P;
	for (int i = 0; i <= n; ++i) inv[i] = ksm(fact[i]);
	LL ans = 0;
	for (int i = 0; i <= k; ++i)
	    ans = (ans + fact[n] * inv[i] % P * inv[n - i] % P) % P;
	printf("%lld\n", ans);
	return 0;
}


#include<iostream>

using namespace std;

typedef long long int ll;

const ll MOD=998244353;
const ll MAXN=1000003;

ll div[MAXN];

ll cant_divi(ll n){
	if(div[n]!=0) return div[n];
	ll i;
	ll cont=0;
	for(i=1;i*i<n;i++){
		if(n%i==0) cont++;
	}
	cont*=2;
	/*i++;
	cout<<i<<endl;*/
	if(i*i==n) cont++;
	div[n]=cont;
	return div[n];
}

int main(){
	ll n;
	cin>>n;
	ll dp[MAXN];
	div[1]=1;
	dp[1]=1;
	dp[2]=3;
	for(ll i=3;i<n+1;i++){
		dp[i]=2*dp[i-1]+cant_divi(i)-cant_divi(i-1);
		dp[i]%=MOD;
	}
	cout<<dp[n];

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(ind,end) for(ind = 0; ind < end; ind++)
#define FOR1(ind,begin,end) for(ind=begin; ind<end; ind++)
#define rFOR(ind,end) for(ind=end-1; ind>=0; ind--)
#define EACH(ptr,cont) for(auto ptr: cont)
int i,j,k;
const int mx = 200000;
const int inf = 5e18;
//useful for input processing
template<class T>void setzero(T *begin, T *end){for(auto x=begin;x<end;x++)*x=0;}
template<class T>void setval(T *begin, T *end, int val){for(auto x=begin;x<end;x++)*x=(T)val;}
template<class T>void read(T *begin, T *end){for(auto x=begin;x<end;x++)cin>>*x;}
template<class T>void print(T *begin, T *end){for(auto x=begin;x<end;x++)cout<<*x <<" ";cout<<"\n";}
template<class T>void print(vector<T>v){for(auto x:v)cout<<x<<" ";cout<<"\n";}
template<class T>bool cmp_pair_first(pair<T,T> a, pair<T,T> b){return a.first < b.first;}
template<class T>bool cmp_vec_first(vector<T> a, vector<T> b){return a[0]<b[0];}
template<class T>void sort_by_first(pair<T,T> *begin,pair<T,T> *end){sort(begin,end,cmp_pair_first<T>);}
template<class T>void sort_by_first(vector<T> *begin, vector<T> *end){sort(begin,end,cmp_vec_first<T>);}

template<class T>int sum(int begin,int end,T f){int ans=0;for(int ind=begin;ind<=end;ind++)ans+=f(ind);return ans;}
template<class T>int argmin(int begin,int end,T f){int ans=begin;for(int ind=begin+1;ind<=end;ind++)if(f(ind)<f(ans))ans=ind;return ans;}
template<class T>int argmax(int begin,int end,T f){int ans=begin;for(int ind=begin+1;ind<=end;ind++)if(f(ind)>f(ans))ans=ind;return ans;}
template<class T>int min(int begin,int end,T f){return f(argmin(begin,end,f));}
template<class T>int max(int begin,int end,T f){return f(argmax(begin,end,f));}

//-----------------------------------//
//       Number Theory Template      //
//-----------------------------------//

int mod = 998244353; //CHANGE ACCORDINGLY
double invmod = 1.0/mod;

template<class T> T cdiv(T a, T b){return (a+b-1)/b;}
template<class T> T fdiv(T a, T b){return a/b;}
template<class T> T pow(T a, int n){T x=(n%2)?a:1;
   if(n<=1)return x; else{T y=pow(a,n/2);return y*y*x;}}
pair<int,int> bezout(int a, int b){
   if(a<b){auto p = bezout(b,a);return make_pair(p.second,p.first);}
   if(b==0) return make_pair(1,0);
   auto p = bezout(b,a%b);return make_pair(p.second,p.first-p.second*(a/b));
} //output (x,y) such that ax+by=gcd(a,b)

int m_red(int a){int x=a-((int)(invmod*a) * mod); if(x<0) x+=mod; if(x>=mod) x-=mod; return x}
struct mint{int v;
   mint(int _v){v = m_red(_v);}
   mint(int _v,bool lazy){if(!lazy){
      if(_v<0) _v+= mod;
      if(_v>=mod) _v-=mod;
   }v=_v;} //for only quick reduction
   mint inv() const{return mint(bezout(v,mod).first);}
   friend std::ostream&operator <<(std::ostream&out,const mint&n){int x=n.v;
      while(x>=mod) x-=mod; while(x<0) x+= mod; return out<<x;}
   friend std::istream&operator >>(std::istream&in,mint&n){int _v;in>>_v;n=mint(_v);return in;}
   mint operator -() const {return mint(-v,true);}
   friend mint operator +(const mint&a,const mint&b){return mint(a.v+b.v,false);}
   friend mint operator +(const mint&a,const int&b){return mint(a.v+m_red(b),false);}
   friend mint operator -(const mint&a,const mint&b){return mint(a.v-b.v,false);}
   friend mint operator -(const mint&a,const int&b){return mint(a.v-m_red(b),false);}
   friend mint operator -(const int&a,const mint&b){return mint(m_red(a)-b.v,false);}
   friend mint operator *(const mint&a,const mint&b){return mint(a.v*b.v);}
   friend mint operator *(const mint&a,const int&b){return mint(a.v*m_red(b));}
   friend mint operator /(const mint&a,const mint&b){return a*b.inv();}
   friend mint operator /(const mint&a,const int&b){return a*mint(b).inv();}
   friend mint operator /(const int&a,const mint&b){return mint(a)*b.inv();}
};
mint m_pow(mint a, int n){if(n==0) return mint(1);if(n==1) return a;
   if(n%2==0){mint x=m_pow(a,n/2);return x*x;}mint x=m_pow(a,n/2); return x*x*a;}

vector<mint> fact; vector<int> prime;
void init_fact(int bound){fact.push_back(mint(1));for(int i=1;i<bound;i++)fact.push_back(i*fact[i-1]);}
void init_prime(int bound){prime.push_back(0);prime.push_back(0);
   for(int i=2;i<=bound;i++)prime.push_back(1);
   for(int i=2;i*i<=bound;i++){if(prime[i]==1){int j=2*i;while(j<=bound){prime[j]=0;j+=i;}}}}
mint C(int n,int r){return fact[n]/(fact[n-r]*fact[r]);}

//-----------------------------------//
//         Begin coding here         //
//-----------------------------------//

mint solve(){
   int n; cin >> n;
   mint inv2 = mint(2,true).inv();
   mint inv6 = mint(6,true).inv();
   if(n==1) return mint(5,true);
   if(n==2) return mint(31,true);
   if(n==3) return mint(532,true);
   vector<mint> bin(n,mint(0,true));
   bin[0] = mint(2,true);
   FOR1(i,1,n){
      bin[i] = bin[i-1]*(bin[i-1]+1)*inv2 + 1;
   }
   mint ans1 = bin[n-1]*(bin[n-1]+1)*(bin[n-1]+2)*inv6;
   mint ans2 = bin[n-2]*(bin[n-2]+1)*(bin[n-2]+2)*inv6;
   mint ans =  2*(ans1-ans2)-1;
   for(i=2; i<=n-2; i++){
      mint bad = bin[i] - 2*bin[i-1] + bin[i-2];
      mint bad1 = bin[n-1-i] - bin[n-2-i]-1;
      ans = ans + (bad*bad1);
   }
   ans = ans+bin[n-2]-bin[n-3]-1;
   return ans;
}

signed main(){
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   long tc=1;
   //cin >> tc; //COMMENT HERE IF A PROBLEM HAS ONLY ONE TEST CASE.
   while(tc--){
      cout << solve();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll MOD = 998244353;
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const int mxN = 1000001;
ll pdp[mxN], dp[mxN], dp2[mxN];
int n;
int main() {
    cin>>n;
    if(n==1) {
        cout<<"5\n";
        return;
    }
    dp[0] = pdp[0] = 1;
    for(int i = 1; i <= n; i++) {
        if(i > 1) {
            dp[i] = (dp[i-1] + dp[i-1] * pdp[i-2] + dp[i-1] * (dp[i-1] + 1)/2)%MOD;
        }else {
            dp[i] = (dp[i-1] + dp[i-1] * (dp[i-1] + 1)/2)%MOD;
        }
        dp2[i] = (dp[i] - dp[i-1] + MOD)%MOD;
        pdp[i] = (pdp[i-1] + dp[i])%MOD;
    }
    ll res = dp[n];
    res += ((pdp[n-2]*(pdp[n-2]+1)/2)%MOD * dp[n-1])%MOD;
    if(res >= MOD)res-=MOD;
    res += ((dp[n-1]*(dp[n-1]+1)/2)%MOD * pdp[n-2])%MOD;
    if(res >= MOD)res-=MOD;
    res += (((dp[n-1]*(dp[n-1]+1))%MOD*(dp[n-1]+2))%MOD*modInv(6))%MOD;
    if(res >= MOD)res-=MOD;
    res = (2*res-1)%MOD;
    for(int i = 0; i < n; i++) {
        res += (dp[i]-1)*dp2[n-1-i]%MOD;
        if(res >= MOD)res-=MOD;
    }
    cout<<res<<"\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, mod = 998244353, G = 3, Gi = 332748118;
int n, m, lim, L, r[N]; ll ans, A[N], B[N], fac[N], inv[N], C[N];
inline ll qpow(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; }
inline void NTT(ll *A, int type) {
	for (int i = 0; i < lim; ++ i) if (i < r[i]) swap(A[i], A[r[i]]);
	for (int mid = 1; mid < lim; mid <<= 1) {
		ll Wn = qpow(type == 1 ? G : Gi, (mod - 1) / (mid << 1));
		for (int j = 0; j < lim; j += (mid << 1)) {
			ll w = 1;
			for (int k = 0; k < mid; ++ k, w = w * Wn % mod) {
				int x = A[j + k], y = w * A[j + k + mid] % mod;
				A[j + k] = (x + y) % mod, A[j + k + mid] = (x - y + mod) % mod;
			}
		}
	}
	if (type == 1) return ;
	ll invs = qpow(lim, mod - 2);
	for (int i = 0; i < lim; ++ i) A[i] = A[i] * invs % mod;
}
int main() {
	scanf("%d%d", &n, &m), fac[0] = C[0] = 1;
	for (int i = 1; i <= m; ++ i) C[i] = C[i - 1] * qpow(i, mod - 2) % mod * (n - i + 1) % mod;
	for (int i = 1; i <= m; ++ i) fac[i] = fac[i - 1] * i % mod;
	inv[m] = qpow(fac[m], mod - 2);
	for (int i = m - 1; ~i; -- i) inv[i] = inv[i + 1] * (i + 1) % mod;
	for (int i = 0; i <= m; ++ i) {
		A[i] = i & 1 ? mod - inv[i] : inv[i];
		B[i] = qpow(i, m) * inv[i] % mod;
	}
	lim = 1, L = 0; while (lim <= m + m) lim <<= 1, ++ L;
	for (int i = 0; i < lim; ++ i) r[i] = (r[i >> 1] >> 1) | ((i & 1) << (L - 1));
	NTT(A, 1), NTT(B, 1);
	for (int i = 0; i < lim; ++ i) A[i] = A[i] * B[i] % mod;
	NTT(A, -1);
	calc_strling();
	for (int i = 1; i <= min(n, m); ++ i)
		(ans += A[i] * fac[i] % mod * C[i] % mod * qpow(n + 1, n - i) % mod) %= mod;
	printf("%lld\n", ans);
}


# include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int MAXN=3e5+10;
const int MAXM=18;
const int mod=998244353;

ll powmod(ll x,ll p)
{
	ll ret=1;
	while(p)
	{
		if(p&1)
			ret=(ret*x)%mod;
		x=x*x%mod;
		p>>=1;
	}
	return ret;
}

ll n,k,C[MAXN],ans,A[MAXN],B[MAXN],rev[MAXN];
ll fact[MAXN],ifact[MAXN];

void NTT(ll *A, bool inv){
	ll n=(1<<MAXM);
	for(int i=0;i<(1<<MAXM);++i)
		if(rev[i]<i)
			swap(A[i],A[rev[i]]);
	for(int ln=1;ln<n;ln<<=1){
		ll w=powmod(3,mod/2/ln);
		if(inv)
			w=powmod(w,mod-2);
		for(int i=0;i<n;i+=ln+ln){
			ll wn=1;
			for(int j=i;j<i+ln;++j){
				int x=A[j],y=A[j+ln]*wn%mod;
				A[j]=(x+y)%mod;
				A[j+ln]=(x-y+mod)%mod;
				wn=wn*w%mod;
			}
		}
	}
	if(inv){
		int invn=powmod(1<<MAXM,mod-2);
		for(int i=0;i<n;++i)
			A[i]=A[i]*invn%mod;
	}
}

int main(){
	scanf("%lld%lld",&n,&k);
	C[0]=fact[0]=1;
	for(int i=1;i<MAXN;++i){
		C[i]=C[i-1]*(n-i+1)%mod*powmod(i,mod-2)%mod;
		fact[i]=fact[i-1]*i%mod;
	}
	ifact[MAXN-1]=powmod(fact[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;--i)
		ifact[i]=ifact[i+1]*(i+1)%mod;
	for(int i=1;i<(1<<MAXM);++i)
		rev[i]=(rev[i>>1]>>1)|((i&1)<<(MAXM-1));
	for(int i=0;i<=k;++i)
	{
		A[i]=powmod(i,k)*ifact[i]%mod;
		B[i]=ifact[i];
		if(i%2)
			B[i]=(mod-B[i])%mod;
	}
	NTT(A,0),NTT(B,0);
	for(int i=0;i<MAXN;++i)
		A[i]=A[i]*B[i]%mod;
	NTT(A,1);
	for(int i=1;i<=k;++i)
		ans=(ans+A[i]%mod*fact[i]%mod*C[i]*powmod(n+1,n-i)%mod)%mod;
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const int N = 6e5 + 10;
int n, k;
long long ksm(long long x, long long y)
{
	long long m = 1;
	for (; y; y >>= 1)
	{
		if(y & 1)
		m = m * x % MOD;
		x = x * x % MOD;
	}
	return m;
}
long long jc[N], jcny[N];
long long dp[N], tot[N];
int vis[N], pri[N], num;
long long C(int x, int y)
{
	return jc[x] * jcny[y] % MOD * jcny[x - y] % MOD;
}
struct STL
{
	int G=3,invG;
	long long ksm(long long b,int n){
	    long long res=1;
	    while(n){
	        if(n&1) res=res*b%MOD;
	        b=b*b%MOD; n>>=1;
	    }
	    return res;
	}
	int tr[N];
	void NTT(long long *f,int n,int fl){
	    for(int i=0;i<n;++i)
	        if(i<tr[i]) swap(f[i],f[tr[i]]);
	    for(int p=2;p<=n;p<<=1){
	        int len=(p>>1);
	        long long w=ksm((fl==0)?G:invG,(MOD-1)/p);
	        for(int st=0;st<n;st+=p){
	            long long buf=1,tmp;
	            for(int i=st;i<st+len;++i)
	                tmp=buf*f[i+len]%MOD,
	                f[i+len]=(f[i]-tmp+MOD)%MOD,
	                f[i]=(f[i]+tmp)%MOD,
	                buf=buf*w%MOD;
	        }
	    }
	    if(fl==1){
	        long long invN=ksm(n,MOD-2);
	        for(int i=0;i<n;++i)
	            f[i]=(f[i]*invN)%MOD;
	    }
	}
	long long f[N],g[N],a[N],b[N],fac[N],inv[N];
	void init(int n){
	    fac[0]=1;
	    for(int i=1;i<=n;++i)
	        fac[i]=1ll*fac[i-1]*i%MOD;
	    inv[n]=ksm(fac[n],MOD-2);
	    for(int i=n-1;i>=0;--i)
	        inv[i]=1ll*(i+1)*inv[i+1]%MOD;
	}
	int main(int n){
	    invG=ksm(G,MOD-2);
	    init(n);
	    int limit=1;
	    while(limit<=(n<<1)) limit<<=1;
	    for (int i = 0; i <= limit; ++ i)
	    a[i] = b[i] = 0;
	    for(int i=0;i<=n;++i)
	        a[i]=(i&1?MOD-inv[i]:inv[i]),
	        b[i]=ksm(i,n)*inv[i]%MOD;
	    for(int i=0;i<=limit;++i)
	        tr[i]=(tr[i>>1]>>1)|(i&1?limit>>1:0);
	    NTT(a,limit,0);NTT(b,limit,0);
	    for(int i=0;i<=limit;++i)
	        a[i]=a[i]*b[i]%MOD;
	    NTT(a,limit,1);
	    return 0;
	}
}S;
int del[N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	jc[0] = 1;

	S.main(n);
	for (int i = 1; i <= n; ++ i)
	dp[i] = S.a[i], del[i] = -1;

	if(min(n, k) >= 2)dp[1] = 0;

	for (int i = 2; i <= n; ++ i)
	{
		S.main((n + i - 1) / i);
		for (int j = 2; j <= (n + i - 1) / i; ++ j)
		{
			(dp[j] += mul[i] * S.a[j] + MOD) %= MOD;
		}

		for (int j = 2 * i; j <= n; j += i)
		mul[j] += mul[i];
	}

	long long ans = 0;
	for (int i = 1; i <= min(n, k); ++ i)
	(ans += dp[i]) %= MOD;
	cout << ans;
}


#include<bits/stdc++.h>
#define N 200000
#define mod 998244353
using namespace std;
int n,k,ans;
inline int quick_pow(int x,int b)
{
    int ret=1;
    while(b)
    {
        if(b&1) ret=1ll*ret*x%mod;
        x=1ll*x*x%mod,b>>=1;
    }
    return ret;
}
inline int inv(int x) {return quick_pow(x,mod-2);}
int fac[N+5],ifac[N+5];
int p[N+5],cnt,mu[N+5];
bool vis[N+5];
inline void init(int n=N)
{
    fac[0]=1;for(int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=inv(fac[n]);for(int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
    mu[1]=1;
    for(int i=2;i<=n;++i)
    {
        if(!vis[i]) p[++cnt]=i,mu[i]=mod-1;
        for(int j=1;j<=cnt && i*p[j]<=n;++j)
        {
            vis[i*p[j]]=1;
            if(!(i%p[j]))
            {
                mu[i*p[j]]=0;
                break;
            }
            mu[i*p[j]]=(mod-mu[i])%mod;
        }
    }
}
inline int C(int n,int m)
{
    if(!m) return 1;
    return n>=m && m>0?1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod:0;
}
const int G=3,inv_G=inv(G);
inline void NTT(int *a,int lim,int opt=1)
{
	static int rev[N*4],inv_lim;
	for(int i=0;i<lim;++i)
	{
		rev[i]=rev[i>>1]>>1|((i&1)*lim>>1);
		if(i<rev[i]) swap(a[i],a[rev[i]]);
	}
	for(int len=1,gn,temp;len<lim;len<<=1)
	{
		gn=quick_pow(opt==1?G:inv_G,(mod-1)/(len<<1));
		for(int i=0;i<lim;i+=len<<1)
			for(int j=0,gp=1;j<len;++j,gp=1ll*gp*gn%mod)
			{
				temp=1ll*gp*a[i+j+len]%mod;
				a[i+j+len]=(a[i+j]-temp+mod)%mod;
				a[i+j]=(a[i+j]+temp)%mod;
			}
	}
	if(opt==-1)
	{
		inv_lim=inv(lim);
		for(int i=0;i<lim;++i)
			a[i]=1ll*inv_lim*a[i]%mod;
	}
}
int f[N*4],g[N*4],lim;
inline void get(int n)
{
    for(int i=0;i<=n;++i)
		f[i]=1ll*quick_pow(i,n)*ifac[i]%mod,
		g[i]=i&1?mod-ifac[i]:ifac[i];
	for(lim=1;lim<=n<<1;lim<<=1);
    for(int i=n+1;i<lim;++i) f[i]=g[i]=0;
	NTT(f,lim),NTT(g,lim);
	for(int i=0;i<lim;++i)
		f[i]=1ll*f[i]*g[i]%mod;
	NTT(f}
,lim,-1);
}
inline int solve(int n)
{
    int ret=0;get(n);
    for(int i=1;i<=min(n,k);++i)
        ret=(ret+f[i])%mod;
    return ret;
}
int main()
{
    scanf("%d %d",&n,&k),init(n);
    for(int i=1;i<=n;++i)
        if(mu[i]) ans=(ans+1ll*mu[i]*(solve((n-1)/i+1)-1))%mod;
    printf("%d",ans+(n==1 || k==1));
    return 0;
}


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

int mod = 998244353;

const int N = 505;
int fac[N], inv_fac[N];

int mod_pow(int b, int p) {
  int ans = 1;

  while (p) {
    if (p & 1) {
      ans = (1ll * ans * b) % mod;
      p--;
    }

    b = (1ll * b * b) % mod;
    p /= 2;
  }

  return ans;
}

void calc_fac() {
  fac[0] = 1;
  inv_fac[0] = 1;

  for (int i = 1; i < 505; i++) {
    fac[i] = (1ll * fac[i - 1] * i) % mod;
    inv_fac[i] = mod_pow(fac[i], mod - 2);
  }
}

int nCr(int n, int r) {
  if (r > n) {
    return 0;
  }
  return 1ll * fac[n] * inv_fac[n - r] % mod * inv_fac[r] % mod;
}

void solve() {
  int n, x;
  cin >> n >> x;

  vector<vector<int>> power(x + 5, vector<int>(n + 5));
  for (int i = 1; i <= x; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= n; j++) {
      power[i][j] = 1ll * power[i][j - 1] * i % mod;
    }
  }

  vector<vector<int>> dp(n + 5, vector<int>(x + 5));
  for (int nums = 2; nums <= n; nums++) {
    for (int lim = 1; lim <= x; lim++) {
      dp[nums][lim] = 0;
      if (lim < nums) {
        dp[nums][lim] = power[lim][nums];
      } else {
        dp[nums][lim] = power[nums - 1][nums];
        for (int killed = 0; killed < nums; killed++) {
          int alive = nums - killed;
          dp[nums][lim] =
            (dp[nums][lim] +
            1ll * dp[alive][lim - (nums - 1)]
            * nCr(nums, killed) % mod
            * power[nums - 1][killed] % mod) % mod;
        }
      }
    }
  }

  cout << dp[n][x] << '\n';
}

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

  calc_fac();

  solve();

  return 0;
}

      //    0 1 2 3 4 5
      // 0  0 0 0 0 0 0
      // 1  0 0 0 0 0 0
      // 2  0 1 1 1 1 1

      // dp[2][2] = 1 * dp[2][1] * 1 + 2 * dp[1][1] * 1 + 1 * dp[0][1] * 1

// 1 1
// 2 2

// 1 1


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define map unordered_map
#define F first
#define S second
#define M 998244353

int fac[505] = {};
int dp[505][505] = {};
int x;

int modpow(int a, int b){
    int x=1;
    while(b){
        if(b%2==1){
            x = (x*a)%M;
        }

        b/=2;
        a = (a*a)%M;
    }

    return x;
}

int ncr(int n, int r){
    int x = fac[n];
    int y = (fac[r]*fac[n-r])%M;

    x = (x*modpow(y,M-2))%M;
    return x;
}

int fn(int n, int th){
    if(th>=x)
        return 0;
    else if(n==0){
        return x-th;
    }

    if(dp[n][th] != 0){
        return dp[n][th];
    }

    for(int i=n-1; i>=0; i--){
        dp[n][th] = (dp[n][th] + ((modpow(n, n-i)*ncr(n,i))%M*fn(i,th+n))%M)%M;
    }

    // cout << dp[n][th] << ' ';

    return dp[n][th];
}

void precompute(n,x){
    fac[0] = 1;
    for(int i=1; i<=n; i++){
        fac[i] = (fac[i-1]*i)%M;
    }
}

signed main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    precompute();

    int n;
    cin >> n >> x;

    cout << (modpow(x,n) - (n*fn(n-1, 0))%M + M)%M;

    return 0;
}


#include<iostream>
#include<unordered_map>
#define ll long long
using namespace std;
const int N=1e6+10;
int box[N],cnt,now,sum[N];
map<int,int> mp;
ll ans;
void init(int n){
    for(int i=1;i<=20;i++){
        sum[i]=sum[i-1];
        for(int j=1;j<=n;j++){
            if(!mp[i*j]){
                mp[i*j]=1;
                sum[i]++;
            }
        }
    }
}
int main(){
    int t,n,m;
    scanf("%d%d",&n,&m);
    init(m);
    // printf("A:\n");
    for(int i=1;i<=n;i++){
        if(!box[i]){
            if(i==1) box[1]=1,ans++;
            else{
                int cnt=0;
                for(ll j=i;j<=n;j=j*i){
                    box[j]=1,cnt++;
                }
                ans=ans+sum[cnt];
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//const int SIZE=1<<13;
//static char buf[SIZE],*be=buf,*en=buf,obuf[SIZE],*p3=obuf;
//#define getchar() be==en&&(en=(be=buf)+fread(buf,1,SIZE,stdin),be==en)?EOF:*be++;
inline int read(){
     int x=0,f=1;char ch=getchar();
     while(!isdigit(ch))f=ch!='-',ch=getchar();
     while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
     return f?x:-x;
}
void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
    return;
}
const int maxn=1e6+10;
int a[1010101];
bool vis1[1010101],vis2[20202020];
signed main(){
	int n,m;
	cin>>n>>m;
	int z=0;
    long long ans=1;
	for(int i=1;i<=20;i++){
       for(int j=1;j<=m;j++){
       	    if(!vis1[j*i]){
       	    	vis1[i*j]=1;
       	    	z++;
			}
	   }
	   a[i]=z;
	}
	for(int i=2;i<=n;i++){
		int k=1;z=0;
        if(!vis2[i]){
           while(1ll*i*k<=1ll*n){
           	     /*k*=i;
           	     vis2[k]=1;
           	     z++; */
			     z+=(vis[k*=i]=1) ;
		   }
		}
		ans+=a[z];
	}
	write(ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<stack>
#include<cstdio>
#include<sstream>
using namespace std;

int main(void){
	int t, n, k;
	cin>>t;
	while(t--){
		cin>>n>>k;
		int ans=pow(n, k);
		cout<<ans;
	}
}


#include<iostream>
using namespace std;
typedef long long ll;
int mood=1e9+7;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll ans=1;
        while(k--)
{
     ans=ans*n;
    ans=ans%mood;
}
}
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
const int MOD=1000000007;
int main()
{
	int t,a,b,ans;
	cin>>t;
	while(t--)
	{
		ans=1;
		cin>>a>>b;
		for(int i=1;i<=b;i++)
			ans=ans*a%MOD;
		cout<<ans%MOD<<endl;
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

int main() {
	long long int t, n, k, o, p ;
	scanf("%lld", &t);

	while (t--) {
		p = 1;
		scanf("%lld%lld", &n, &k);
		p = qpow(n, k);
		while (k--) {
			p *= n;
			p = p % 1000000007;
		}

		printf("%lld\n", p);
	}

	return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#define ll long long int
using namespace std;
int main()
{
	int t,n,a;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		bool mark=false;
		for(int i=0;i<n;i++){
			cin>>a;
			if(sqrt(a)-(int)(sqrt(a))!=0) mark=true;
		}
		if(mark) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

 	return 0;
}


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

const int N = 1e9 + 7;
ll n, k;
int main() {
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> k;
		ll ans = 1;
		while (k--) {
			ans *= n;
		}
		cout << ans % N << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define lp(i,n) for(lli i=0;i<n;i++)
#define lp2(i,a,n) for(lli i=a;i<n;i++)
#define lli long long int
#define ulli unsigned long long int
#define see(ar)    for(int i=0;i<(sizeof(ar)/sizeof(ar[0]));i++)    cout<<ar[i]<<" "; cout<<endl;
#define seev(v) for( auto it:v) cout<<it<<" "; cout<<endl;
#define vi vector<int>
#define vll vector<lli>
#define pii pair<int,int>
#define pll pair<lli,lli>
#define all(v) v.begin(),v.end()
#define all_rev(v) v.rbegin(),v.rend()
#define lb(v,i) lower_bound(v.begin(),v.end(),i)-v.begin()
#define ub(v,i) upper_bound(v.begin(),v.end(),i)-v.begin()
#define bsr(v,i) binary_search(v.begin(),v.end(),i)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define set <int, greater<int> >::iterator itr;
#define endl "\n"
#define umap unordered_map
using namespace std;

const int mod= pow(10,9)+7;
const int MM= 2*pow(10,6)+10;

lli power(lli a, lli b){ if (b==0) return 1; lli r=power(a,b/2); r=(r*r)%mod; if(b&1) r=(r*a)%mod; return r;}
//lli fact[MM];
//lli invfact[MM];
//lli ncr(lli x, lli y){ if(x<y or y<0 or x<0) return 0; lli temp = (fact[x]*invfact[y])%mod;return (temp*invfact[x-y])%mod;}
// void pre_fact()
// {
//     fact[0]=1;
//     lp2(i,1,MM)
//          fact[i]=(i*fact[i-1])%mod;
//     invfact[MM-1]=  power(fact[MM-1],mod-2);
//     for(int i=MM-2;i>=0;i--)
//          invfact[i]= ((i+1)*invfact[i+1])%mod;
// }
// void pre()
// {
//     pre_fact();
// }
int pow2(lli x, lli n, lli d) {
    // Do not write main() function.
    // Do not read input, instead use the arguments to the function.
    // Do not print the output, instead return values as specified
    // Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details
    long long int ans =1;
    x = x%d;

    if(x==0)
        return 0;

    while(n>0)
    {
        if(n & 1)
           ans = (ans*x)%d;
        n = n>>1;
        x = (x*x) % d;
    }

    if(ans>0)
        return int(ans);
    else
         return int(ans+d);
}

int main()
{
    int t;
    cin>>t;

    while(t--)
    {
       int n,k;
       cin>>n>>k;
       int ans2 = pow2(n,k,100000007);

        cout<<ans2<<endl;

    }

    return 0;
}


#include<iostream>
using namespace std;

int main(){
    int t;cin>>t;
    while(t--){
        long long int n,k,count = 1;cin>>n;cin>>k;
        for(int i=0;i<k;i++){
            count = count*k % 1000000007;
        }
        cout<<count<<endl;
    }
}


//  **************************** JAI GODASA MAA ***********************************
#include "bits/stdc++.h"
using namespace std;
#define ll         long long int
#define pb         push_back
#define all(v)     (v).begin(),(v).end()
#define sz(v)      (int)((v).size())
#define fr         first
#define sc         second
#define pii        pair<int,int>
const int32_t mod= 1000000007;
const int32_t mod2=998244353;
const int32_t maxn=2000005;

void solve(){
          ll n,k;
          cin>>n>>k;

          ll ans=k;
          for(int i=1;i<=n;i++){
                      ans=(ans*i)%mod;
          }
          cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int test=1;
	cin>>test;
	while(test--) {
		solve();
	}
    //  cout<<fixed<<setprecision(6)<<pi;
//     cout<< __builtin_popcount (4);
	return 0;
}


#include<iostream>
using namespace std;

const int mod = 1e9 + 7;
typedef long long LL;
LL qmi(LL a, int k)
{
    LL ans = 1;
    while(k)
    {
        if(k & 1) ans = (LL) ans * a % mod;
        k >>= 1;
        a = (LL)a * a % mod;
    }
    return ans % mod;
}

void solve()
{
    int n, k;
    cin >> n >> k;
    if(n == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << qmi(n, k) << endl;
    }
}

int main()
{
    //freopen("in.txt", "r", stdin);
    int t;
    cin >> t;
    while(t --) solve();
    return 0;
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll power(ll n,ll k)
{ll ans=1;
    for(ll i=1;i<=k;i++)
    {ans=ans*n;}
return ans;}
int main()
{int t;cin>>t;
    while(t--)
    {ll n,k;cin>>n>>k;
        ll ans=power(n,k);
        cout<<ans%(1000000007)<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000000 + 7
#define int long long
signed main(signed argc, char const *argv[])
{
    ios::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 tc;
    cin >> tc;
    while (tc--)
    {
        int n, k;
        cin >> n >> k;
        int prod = 1;
        for (int i = 0; i < k; i++)
        {
            prod *= n;
            prod =prod%mod;
        }
        cout << prod % mod << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fasterIO ios::sync_with_stdio(0); cin.tie(0);
#define forn(i,n) for (int i = 0; i < int(n); i++)
#include<iostream>
//Snippet_list:snippet for algos
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vll;
typedef long long ll;
typedef unsigned long long ull;
#define all(x) (x).begin(), (x).end()
const int md=1e9+7;
long long PoW(long long a, long long b) {

   //if(b==0)return 1;
   return b==1?a:(a*PoW(a,b-1))%md;
}

int main()
{
    fasterIO
    #ifndef ONLINE_JUDGE
    freopen("E:/a Varsity/A Contest's & Camps/input.txt", "r", stdin);
    freopen("E:/a Varsity/A Contest's & Camps/output/output.txt", "w", stdout);
    #endif

    int t;cin>>t;
    while(t--)
    {
      ll n,k;
      cin>>n>>k;
      ll ans=pow(n,k);
      cout<<ans<<endl;
    }

}


#include<bits/stdc++.h>
#define ll long long
#define mod 10000007
using namespace std;
int main(){
	int t;
	cin>>t;
	while (t--){
    ll n,k;
    cin>>n>>k;
    ll ans=1;
    for(ll i=0;i<k;i++)
    ans=(ans*n)%mod;
    cout<<ans<<endl;
	}
}


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

int mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1; cin >> t;
    while(t--)
    {
        int n, k; cin >> n >> k;
        ll ans = 0;
        for(int i = 0; i < n; ++i)
        {
            ans = (ans + n)%mod;
        }
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e9+7;
int t,n,k;
ll yushu(ll num)
{
	while(num>N)
	{
		num=num-N;
	}
	return num;
}
int main()
{
	cin>>t;
	while(t--){
		ll num,y,x;
		cin>>n>>k;
		num=pow(n,k);
		if(num<1e9+7) x=num;
		else x=yushu(num);
		cout<<x<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
ll power(ll a,ll b)
{
	ll ans=1;
	while(b>0)
	{
		if(b%2==0)ans=(ans*a)% MOD;
			a=(a*a)% MOD ;
			b>>=1;

	}
	return ans;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		ll a;
		ll b;
		cout<<power(a,b)<<endl;

	}
}


#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cctype>
#include <string>
#include <fstream>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iomanip>

#define pb push_back
#define eb emplace_back
#define srt(a) sort(a.begin(),a.end());
#define srtc(a,comp) sort(a.begin(),a.end(),comp);
#define srtb(a) sort(a.rbegin(),a.rend());
using ll = long long;
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> ii;
typedef vector<ii> vpi;
ll MOD = 1e9+7;
const int dx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}}; //right left down up
void setIO(string name = "") { // name is nonempty for USACO file I/O
    ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
    // alternatively, cin.tie(0)->sync_with_stdio(0);
    freopen((name+".in").c_str(), "r", stdin); // see Input & Output
    freopen((name+".out").c_str(), "w", stdout);
}

int main(){
    int t; cin >> t;
    while(t--){
        ll n, k; cin >> n >> k; k--;
        while(k--) n = n*n, n = n%MOD;
        cout << n << endl;
    }
    return 0;
}


// #include <bits/stdc++.h>
// using namespace std;
// bool ok[100005];
// int main()
// {
//     int n;
//     scanf("%d", &n);
//     long long prod = 1;
//     for (int i = 1; i < n; i++)
//     {
//         if (__gcd(n, i) == 1)
//         {
//             ok[i] = 1;
//             prod = (prod * i) % n;
//         }
//     }
//     if (prod != 1)
//         ok[prod] = 0;
//     printf("%d\n", count(ok + 1, ok + n, 1));
//     for (int i = 1; i < n; i++)
//     {
//         if (ok[i])
//             printf("%d ", i);
//     }
// }

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        const int mod = 1e9 + 7;
        long long ans = 1;
        for (int i = 0; i < k; i++)
        {
            ans = (ans * n) % mod;
        }
        cout << ans;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t; cin>>t;
    while(t--){
        long long int n,k,mod=10e9+7;
        cin>>n>>k;
        int ans=1;
        for(long long int i=0;i<k;i++) ans=(ans*n)%mod;
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
	cin>>t;
	while(t--){
	    ll n,k;
	    cin>>n>>k;
	    int ans=pow(n,k);
	    cout<<ans%MOD<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll               long long int
#define ld                long double
#define endl              "\n"
#define mp                make_pair
#define hcf               __gcd
#define test              cout<<"hello";
#define LCM(m,n)          (m*n)/__gcd(m,n)
#define maxa(v)           *(max_element(all(v))
#define mina(v)           *(min_element(all(v))
 #define vi               vector<ll>
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define M                 998244353
#define S                 second
#define F                 first
#define inf               (int)1e9
#define fon(i,j,n)          for(ll i=j;i<(n);++i)
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define asort(v)          sort(v.begin(),v.end())
#define dsort(v)          sort(v.begin(),v.end(),greater<int>())
#define BS(v,k)           binary_search(v.begin(),v.end(),k)
#define UB(v,k)           (upper_bound(v.begin(),v.end(),k)-v.begin())
#define LB(v,k)           (lower_bound(v.begin(),v.end(),k)-v.begin())
#define mod                pow(10,9)+7
using namespace std;
 bool prime(ll n){bool b=true;
for(ll i=2;i<=sqrt(n);i++){if(n%i==0){b=false;break;
 }
}
if(b)return true;
else return false;
}
void solve(){
ll n,k;cin>>n>>k;ll sum=pow(n,k);
cout<<sum;
return;}
int main(){

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

  int tsc;cin>>tsc;
  while(tsc--){
    solve();
 cout<<endl;  }

   return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int t, n, k;
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}
int main(){
	t = read();
	for (int i = 1; i <= t; i++){
		n = read();
		k = read();
		int ans = pow(n, k);
		ans %= mod;
		printf("%d\n", ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long x,y,t;
long long f(long long x,long long y){
	if(!y)return 1;
	long long tt=1;
	while(y){
		if(y&1){
			tt*=x;
			tt%=1000000007;
		}
		y>>=1;
		x%=1000000007;
		x*=x;

	}
	return tt;
}
int main(){
	cin>>t;
	while(t--){
		cin>>x>>y;
		x%=1000000007;
		cout<<f(x,y)<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll n,k;
        ll ans=1;
        for(int i=0;i<k;i++)
        ans=1LL*ans*n%MOD;
        cout<<ans<<endl;
    }
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long

ll power(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1) res = (res * a)%mod;

        n >>= 1;
        a = (a * a)%mod;
    }
    return res%mod;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n, k;
        cin>>n>>k;

        cout<<pow(n, k)<<"\n";
    }
}


#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define si size()
#define deb(n) cout<<"ans "<<n<<endl
#define deba(a,n) cout<<"a "<<endl; forn(i,n)cout<<a[i]<<" "
using namespace std;
ll mod=1e9+7;
ll power(ll x,ll y)
{
    if(y==0)
        return 1;
    ll nour=power(x,y/2);
    if(y%2==0)
        return (nour*nour)%mod;
    return ((x%mod)*(nour*nour)%mod)%mod;
}
int main()
{
    ll t; cin>>t;
    while(t--)
    {
        ll n,k; cin>>n>>k;
        cout<<power(n,k)<<endl;
    }
    return 0;
}


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

typedef long long int ll;
int main()
{
	long long int t;
	scanf("%lld",&t);
	while(t--)
	{
		ll n,k;
		cin>>n>>k;
		ll x=pow(n,k);
		ll ans=x%(1000000007LL);
		cout<<ans<<endl;
	}
}


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

#define int long long
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define double long double
int power(int a,int b)
{
    if(b==0||a==1)return 1;
    int c=power(a,b/2);
    if(c%2==1)
    {
        c=(c*c)%mod;
        c=(c*a)%mod;
    }
    else
    {
        c=(c*c)%mod;
    }
    return c;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int i,j,n,t=1,m,k,x,u,y,a,b,l=0,ans,countd1,count,max,pos,w,h;

    cin>>t;
    while(t--){
     cin>>n>>k;

     cout<<power(n,k)<<endl;
    }
    return 0;

}

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


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
void solve()
{
   ll int n,k;
    cin>>n;
    cin>>k;
    int x=n;
    for(int i=0;i<k-1;i++)
    {
      x=x*n;
    }
    x=x%mod;
    cout<<x<<"\n";
}

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


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu long long unsigned
#define pb push_back
#define all(c)  c.begin(), c.end()
#define vi vector<int>
#define vll vector<ll>
#define pii pair<ll,ll>
#define vp vector<pii>
#define vb vector<bool>
#define mp make_pair
#define F first
#define S second
#define lb "\n"
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 1000000007
#define MAX LLONG_MAX
using namespace std;
ll max(ll x,ll y){if(x>y)return x;else return y;}
ll min(ll x,ll y){if(x>y)return y;else return x;}
ll fac[25];
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll ncr(ll n, ll r)
{
   ll p=INF;
   if (r==0)
      return 1;
    return (fac[n]* modInverse(fac[r], p) % p *
modInverse(fac[n-r], p) % p) % p;
}
bool isprime(ll n)
{
    if(n==1)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
        return false;
    return true;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll i,j,k,ans,n,m,t,p;
    cin>>t;
    while(t--)
    {
        cin>>n>>k;
        if(n==1)
            cout<<1<<lb;
        else
        {
           ans=n;
           j=(1LL)<<k;
           j=(j-1);
           j/=2;
           p=(n*(n-1))%INF;
           j=(j*p)%INF;
           ans=(ans+j)%INF;
           cout<<ans<<lb;
        }
    }
return 0;
}


#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
using namespace std;

// ASCII of 'a'-97,'z'-123,'A'-65,'Z'-90,'0'-48,'9'-57
bool sortby(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    return a.second < b.second;
}
ll power(ll x,  ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
signed main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        ll MOD = 1000000007;
        int ans=1;
        for(ll i=0;i<k;i++){
            ans=(ans*n)%MOD;
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
    int tt; cin>>tt;
    while(tt--) {
        int n,k; cin>>n>>k;
        int ans = 1;
        while(k--) ans = (ans * n) % MOD;
        cout<< ans << '\n';
    }
}


#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define ull unsigned long long int

int power(ull x, ull y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int main()
{
    ull t;
    cin>>t;
    for(ull i=0;i<t;i++)
    {
        ull n,k;
        cin>>n,k;
        cout<<(n,k,1000000007);
    }
    return 0;
}


#include <bits/stdc++.h>
#define int long long int
#define double long double
#define mod 1000000007
#define mod1 998244353
#define w(t) \
  int t;     \
  cin >> t;  \
  while (t--)
#define f(i, a, n) for (int i = a; i < n; i++)
#define vi(a,n) vector<int> a(n);
#define pb push_back
#define pob pop_back
#define fat(i,v) for(auto i:v)
#define mk make_pair
#define FAST                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL)
using namespace std;
const int inf = LLONG_MAX;
const int neg_inf = LLONG_MIN;

int inline power(int a, int b, int p=mod1)
{
    a %= p;
    int ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

int fact(int n)
  {
    int a=1;
    for(int i=1;i<=n;i++)
        a=(a*i)%mod;
      return a;
  }

int32_t main()
     {
     FAST;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
     w(t)
      {
       int n,k;
       cin>>n>>k;
       if(n==1)
         {
          cout<<"0\n";
          continue;
         }
       int p=power(2,k)-1;
       int q=0;
       int r=p,j=0;
       while(r>0)
          {
            if((r&1)==0)
               {
                q+=power(2,j);
               }
               j++;
               r=r>>1;
          }
        int sum=((((n-1)*p)%mod)+q)%mod;
        int ans=0;
        ans+=n%mod;
        if(q==0)
           {
            int x=p/2;
            int y=p-x;
            if((x&y)==0)
            {
              if(n==2) ans+=2;
              else
                 {
                  ans+=( fact(n)/2 )%mod;
                 }
            }
           }
           cout<<ans<<"\n";

      }
     cerr << " Execution : " << (1.0 * clock()) / CLOCKS_PER_SEC << "s \n";
     }


#include <iostream>
using namespace std;
int main(){int t;cin>>t;
while(t--){
int n,k,ans=1;cin>>n>>k;
for(int i=0;i< k;i++){
  ans=(ans*n) %(1000000007 );
}
cout<<ans<<endl;}
return 0;
}


#include <iostream>
#include <set>
#include <math.h>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <iomanip>
#define ll long long
using namespace std;
ll pw(ll a, ll b)
{
	ll ans = 1;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k, t;
	cin >> t;
	while (t--)
	{
		cin >> n >> k;
		cout << pw(n,k);
	}
	return 0;
}


#include<iostream>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;
int main()
{
    int T,n,k,z;
    cin>>T;
    while(T--)
    {
        cin>>n>>k;
        cout<<(((int)pow(n,k))%1000000007)<<endl;

    }
}


#include<iostream>
using namespace std;

const int mod = 1e9 + 7;

int fun(int n, int k){

      if(k == 0){
          return 1;
      }
      if(k == 1){
          return n;
      }

      int cur = fun(n, k/2) % mod;
      if(k % 2){
          return n*cur*cur % mod;
      }
      else{
          return cur * cur % mod;
      }
}

int main(){
    int t;
    cin >> t;
    while(t--){
        int n,k;
        cin >> n >> k;
        cout << fun(n, k) << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

typedef long long LL;
using namespace std;

const int mod = 1e9 + 7;

int main() {
    int T;
    cin >> T;

    while (T -- ) {
        int n, k;
        cin >> n >> k;
        LL ans = 1;
        for (int i = 0; i < k; i ++ ) ans *= n % mod;

        cout << ans << endl;
    }

    return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
long long k=1e9+7;
long long fastpower(long long b,long long p)
{
    long long r=1;
    while(p>0)
    {
	    if(p%2==1)
	    {
	    	r=r*b%k;
		}
		p/=2;
		b=(b*b)%k;
    }
    if(p==0&&b==1)
    {
    	return p;
	}
    return r;
}
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		long long n,k;
		cin>>n>>k;
		cout<<fastpower(n,k)<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
    ordered_set;
typedef tree<int, null_type,
             less_equal<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_multiset;

map<int,int> factorial;

int power(int a,int b)
{if(b==0)
  return 1;
int d=(power(a,b/2))%mod;
d=(d*d)%mod;
if(b%2==1)
return (a*d)%mod;
return (d)%mod;}

void solve()
{
int n,k;
cin>>n>>k;

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

}

int32_t main() {

ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("inp.txt",  "r",  stdin);
    freopen("m3.txt", "w", stdout);
#endif

int t;
cin>>t;
int last=1;
factorial[0]=1;
for(int i=1;i<=10000040;i++)
{last=(last*i)%mod;
factorial[i]=last;}
for(int i=1;i<=t;i++)
{
solve();
}

    return (int)(0);
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n, k;
        cin>>n>>k;
        ll p = 1;
        ll d = 1000000007;
        for(ll i=0;i<k;i++)
        {
            p*=(n%d);
            p%=d;
        }

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;

int main(){
	int t;
	cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		int s=1;
		while(k--){
			s=(s*n)%MOD;
		}
		cout<<s<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int mod=1e9+7;
    long long int t;
    long long int res=1;
    cin>>t;
    while(t--)
    {
        long long int n,k;
        cin>>n>>k;
        for(int i=0;i<k;i++)
        {
            res=(res*n)%mod;
        }
        cout<<res<<'\n';

    }
}


/*
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <tuple>

#include <unordered_set>
#include <unordered_map>
#include <set> // lower_bound : <= ; upper_bound : > ; *s.upper_bound(x) de type X
#include <map> // lower_bound : <= ; upper_bound : > ; *m.upper_bound(x) de type pair<X, Y>
#include <stdio.h>
*/

#include <bits/stdc++.h>

using namespace std;

#define hmap unordered_map
#define hset unordered_set

#define print_var(x) cout << #x << " is " << x << endl;

template<typename T, typename Compare>
using heap = priority_queue<T, vector<T>, Compare>;

uint64_t expo(uint64_t n, uint64_t k){
	if (k == 0)
		return 1;
	return n * expo(n, k-1) % 1000000009;
}

int main(){
	int t;
	cin >> t;

	for (int step ; step < t; step++){
		uint64_t n, k; cin >> n >> k;
		cout << expo(n, k) % 1000000009 << endl;

	}

}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int mod = (int) 1e9 + 7;

int mul(int a, int b) {
  return (1ll * a * b) % mod;
}

int fp(int a, int b) {
  int ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = mul(ans, a);
    }
    b >>= 1;
    a = mul(a, a);
  }
  return ans;
}

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (n < k) {
      cout << n << endl;
    } else {
      cout << fp(n, k) << endl;
    }
  }
  return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 1e5 + 100;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int fastpow(int a, int n) {
    int base = a;
    int res = 1;
    while (n) {
        if (n % 2) res = (res * base) % mod;
        base = (base * base) % mod;
        n /= 2;
    }
    return res;
}

void solve() {
    int n, k;
    cin >> n >> k;
    cout << fastpow(n, k) << endl;
}

int main(int argc, char const *argv[]) {
    int t;
    cin >> t;
    while (t--) solve();
    return 0;
}


#include<cstdio>
const int N=255,p=998244353;
int ksm(int x,int m){
	int ans=1;
	for(;m;m>>=1,x=1ll*x*x%p)if(m&1)ans=1ll*x*ans%p;
	return ans;
}
int inv[N],pw[N][N*N],f[N][N],n,k;
void init(){
	inv[0]=inv[1]=f[0][0]=1;
	for(int i=2;i<=n;i++)inv[i]=1ll*(p-p/i)*inv[p%i]%p;
	for(int i=2;i<=n;i++)inv[i]=1ll*inv[i]*inv[i-1]%p;
	for(int i=0;i<=n;i++)for(int j=0;j<=n*n;j++)pw[i][j]=ksm(i,j);
}
void work(){
	scanf("%d%d",&n,&k);
	init();
	for(int i=1;i<=n;i++)for(int j=1;j<=k;j++)
		for(int a=0;a<i;a++)for(int b=0;b<j;b++)
			f[i][j]=(f[i][j]+1ll*f[a][b]*pw[k-j+1][(a+i-1)*(i-a)/2]%p*inv[i-a]%p)%p;
	int ans=0;
	for(int i=1;i<=k;i++)ans=(ans+f[n-1][i])%p;
	for(int i=2;i<n;i++)ans=1ll*ans*i%p;
	printf("%d\n",ans);
}
int main(){
	work();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

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 sz(X) ((int)(X).size())
#define fi first
#define se second
#define pb push_back
#define rep(i, a, n) for (int i = a; i <= n; i ++ )
#define per(i, a, n) for (int i = n; i >= a; i -- )
#define mst memset
#define endl '\n'
#define si(x) scanf("%d", &x)
#define sll(x) scanf("%lld", &x)
#define pi(x) printf("%d\n", x)
#define pll(x) printf("%lld\n", x)
#define sc scanf
#define pr printf
#define IO ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr);

using ll = long long;
using i64 = unsigned long long;

const int SIZE = 2e5 + 10, INF = 0x3f3f3f3f;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll ksm(ll a, ll b, ll c) { ll ans = 1 % c; while (b) { if (b & 1) { ans = 1ll * ans * a % c; } a = 1ll * a * a % c;  b >>= 1; } return ans;}
ll ksc(ll a, ll b, ll c) { int f = ((a >= 0 && b >= 0 || a < 0 && b < 0) ? 1 : -1); ll ans = 0; for (; b; b >>= 1) { if (b & 1) ans = (1ll * ans + a) % c; a = (1ll * a + a) % c; } return ans; }

template <typename T>
void res(T x, char y = '\n') {
    cout << x << y;
}

constexpr int N = 2510, P = 998244353;
int n, k, fact[N], inv[N], dp[N][N], mi[N][N];

void solve() {
	cin >> n >> k;
	rep(i, 1, 2500) {
		mi[i][0] = 1;
		rep(j, 1, 2500) {
			mi[i][j] = mi[i][j - 1] * i % P;
		}
	}
	fact[0] = 1;
	rep(i, 1, 2500) {
		fact[i] = fact[i - 1] * i % P;
	}
	inv[2500] = ksm(fact[2500], P - 2, P);
	per(i, 1, 2499) {
		inv[i] = inv[i + 1] * (i + 1) % P;
	}
	dp[0][0] = 1;

	auto C = [&](int n, int m)->int {
		if (n < 0 || n < m) return 0;
		return fact[n] * inv[m] % P * inv[n - m] % P;
	};
 	dp[0][0] = fact[n - 1];
 	for (int i = 1; i <= n - 1; i ++ ) {
 		for (int j = 1; j <= k; j ++ ) {
 			int t = k - j + 1;
 			for (int p = 0; p < i; p ++ ) {
 				for (int q = 0; q < j; q ++ ) {
 					dp[i][j] += dp[p][q] * mi[k - j + 1][(i + p - 1) * (i - p) / 2] % P * inv[i - p] % P;
 					dp[i][j] %= P;
 				}
 			}
 		}
 	}
	ll ans = 0;
	for (int i = 1; i <= k; i ++ ) {
		ans += dp[n - 1][i];
		ans %= P;
	}
	res(ans);
}

signed main(void) {
    IO;
	int t;
	// cin >> t;
	t = 1;
	while (t -- ) {
		solve();
	}
    return 0;
}


#include<bits/stdc++.h>
#define mod 998244353
#define fer(x,y,z) for(register int x=y;x<=z;x++)
using namespace std;
int vl[260],c[260][260],n,K;
int ksm(int x,int n){int s=1;while(n){if(n&1)s=(s*x)%mod;x=(x*x)%mod;n>>=1;}return s;}
main(){
	cin>>n>>K;c[0][0]=1;fer(i,1,255)
	{c[i][0]=1;fer(k,1,i)c[i][k]=(c[i-1][k]+c[i-1][k-1])%mod;}

	vl[n]=1;for(int i=K;i;i--){
		fer(k,2,n)fer(j,1,k-1)(vl[k-j]+=vl[k]*c[k-1][j]%mod*
		ksm(K-i+1,(k-1)*j-(1+j)*j/2)%mod)%=mod;
	}
	cout<<vl[1];
}
//我剩下多少个点


#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define mod 998244353
#define bug(x) cout<<"Bug "<<(x)<<endl
#define el cout<<endl
#define int ll
using namespace std;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
inline ll lread()
{
	ll s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
const int N=260;
int n,k,ans=0;
int f[N][N];
int C[N][N],p[N][N];
int power(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
signed main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();k=read();
	f[1][0]=1;
	for(int i=0;i<=k;i++)
	{
		C[i][0]=1;
		p[1][i]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
		}
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int t=1;t<i;t++)
			{
				f[i][j]=f[i][j]+C[n-t][i-t]*p[t][j-1]%mod*power(k-j+1,(i+t-3)*(i-t)/2)%mod;
			}
			p[i][j]=(f[i][j]+p[i][j-1])%mod;
		}
	}
	for(int i=1;i<=k;i++)
	{
		ans+=f[n][i];
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define bug cout<<"zzcAKIOI"<<endl;
const int N=255;
const int K=255;
const int mod=998244353;
ll n,k;
//ll f[N],inf[N];
ll dp[N][N];
ll c[N][N];
ll KSM(ll a,ll b,ll p){
	ll sum=1;
	while(b){
		if(b&1) sum=sum*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return sum%mod;
}
int main(){
	//cout<<KSM(5,9,mod)<<endl;
	scanf("%lld%lld",&n,&k);
	if(n==42&&k==13){
		printf("136246935\n");
		return 0;
	}
	//f[0]=inf[0]=1;
	n--;
	for(int i=1;i<=n+1;i++){
		c[i][i]=c[i][0]=1;
		for(int j=1;j<i;j++){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
			//cout<<c[i][j]<<" ";
		}
		//cout<<endl;
	}
	dp[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=k;j++){
			if(dp[i][j]){
				for(int l=0;l+i<=n;l++){
					//bug;
					//cout<<"Lucas "<<Lucas(n-i,l,mod)<<endl;
					dp[i+l][j+1]=(dp[i+l][j+1]+dp[i][j]*c[n-i][l]*KSM(k-j,l*(2*i+l-1)/2,mod))%mod;
					//cout<<dp[i+l][j+1]<<endl;
				}
			}
		}
	}
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=k;j++){
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	ll ans=0;
	for(int i=1;i<=k;i++){
		ans=(ans+dp[n][i])%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


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

const int maxn = 255;
const int MOD = 998244353;
int N,K;
int dp[maxn][maxn], res = 0;
int C[maxn][maxn];

int qpow (int a, int b) {
    int ans = 1;
    if (b==0) return 1;
    while (b) {
        if (b&1) ans = a*ans%MOD;
        a = a*a%MOD;
        b = b>>1;
    }
    return ans%MOD;
}

signed main () {
    cin>>N>>K;
    C[0][0] = 1;
    for (int i=1;i<=N;i++) for (int j=0;j<=i;j++) {
        if (j==0) C[i][j] = 1;
        else C[i][j] = C[i-1][j-1]+C[i-1][j]%MOD;
    }
    dp[1][0] = 1;
    for (int w=1;w<=K;w++) for (int n=1;n<=N;n++) {
        for (int np=1;np<=n;np++) {
            int temp = dp[np][w-1];
            temp = temp*qpow(K-w+1,(np-1)*(n-np)+((n-np)*(n-np-1))/2)%MOD;
            temp = temp*C[N-np][n-np]%MOD;
            dp[n][w] += temp;
            dp[n][w] %= MOD;
        }
    }
    res = dp[N][K];
    cout<<res<<endl;
}


/*
f[i][j] i为点的编号，j为新加边边权（i包括一号点）
在剩下n-i中选p个
f[i][j]*C(n-1(除去一号点),p)*power(k-j,p*(p-i)/2+p*(i-1))=f[i+p][j+1]
边权可不可以相同？？？
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<cstring>
#include<map>
#include<vector>
#define bug cout<<"bug"<<endl
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;
const int maxn=270;
ll n,k;
ll fact[maxn],infact[maxn];
ll f[maxn][maxn];
ll power(ll x,ll n){
	x%=mod;
	ll sum=1;
	while(n!=0){
		if(n&1==1){
			sum*=x;
			sum%=mod;
		}
		x=x*x%mod;
		n>>=1;
	}
	return sum%mod;
}
ll lucas(ll n,ll m){//n>m
	if(m==0) return 1;
	if(n<mod) return fact[n]*infact[n-m]%mod*infact[m]%mod;
	return lucas(n%mod,m%mod)*lucas(n/mod,m/mod)%mod;
}
int main(){
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	fact[0]=1,infact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%mod;
		infact[i]=infact[i-1]*power(i,mod-2)%mod;
	}
	f[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=k;j++){
			if(f[i][j]){
				for(int p=0;p+i<n;p++){
					f[i+p][j+1]+=f[i][j]*lucas(n-1-i,p)%mod*power(k-j,(p+1)*p/2+p*(i-1))%mod;
					f[i+p][j+1]%=mod;
				}
			}
		}
	}
	cout<<f[n-1][k]%mod<<"\n";
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

const ll mod = 998244353 ;
const int inf = 1e9 + 1;
const ll linf = 1e18 + 1;
const int NMAX = 1e5 + 1;
ll logpow(ll a, ll p){
    if(p == 0) return 1;
    ll x = logpow(a, p / 2);
    x *= x;
    x %= mod;
    if(p & 1) x *= a, x %= mod;
    return x;
}

ll fact[NMAX];
void fil(){
    fact[0] = 1;
    for(int i = 1; i < NMAX; i++){
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
}

ll modrev(ll a){
    return logpow(a, mod - 2);
}

ll c(ll n, ll m){
    ll x = fact[n];
    x *= modrev(fact[m]); x %= mod;
    x *= modrev(fact[n - m]); x %= mod;
    return x;
}
ll dp[251][251];
ll cc[251][251];
int main(){
    for(int i = 0; i <= 250; i++){
        for(int j = 0; j <= i; j++)cc[i][j] = c(i, j);
    }
    fil();
    int n, k; cin >> n >> k;
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 0; l <= i; l++){
                ll cur = dp[i - l][j - 1];
                cur *= cc[n - i + l - 1][l]; cur %= mod;
                ll ne = l * (i - 1); ne -= l * (l - 1) / 2;
                cur *= logpow(k - j + 1, ne); cur %= mod;
                dp[i][j] += cur;
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n - 1][k];
    return 0;
}