There are $$$n$$$ heroes fighting in the arena. Initially, the $$$i$$$-th hero has $$$a_i$$$ health points.The fight in the arena takes place in several rounds. At the beginning of each round, each alive hero deals $$$1$$$ damage to all other heroes. Hits of all heroes occur simultaneously. Heroes whose health is less than $$$1$$$ at the end of the round are considered killed.If exactly $$$1$$$ hero remains alive after a certain round, then he is declared the winner. Otherwise, there is no winner.Your task is to calculate the number of ways to choose the initial health points for each hero $$$a_i$$$, where $$$1 \le a_i \le x$$$, so that there is no winner of the fight. The number of ways can be very large, so print it modulo $$$998244353$$$. Two ways are considered different if at least one hero has a different amount of health. For example, $$$[1, 2, 1]$$$ and $$$[2, 1, 1]$$$ are different.

The only line contains two integers $$$n$$$ and $$$x$$$ ($$$2 \le n \le 500; 1 \le x \le 500$$$).

Print one integer — the number of ways to choose the initial health points for each hero $$$a_i$$$, where $$$1 \le a_i \le x$$$, so that there is no winner of the fight, taken modulo $$$998244353$$$.

using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp9
{
    class Program
    {

        static long mod = 998244353L;
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            int n = input[0], x = input[1];
            var xar = new long[n + 1, n + 1];
            for (int i = 1; i <= n; i++)
            {
                xar[i, 0] = 1;
                for (int j = 1; j <= n; j++)
                    xar[i, j] = (xar[i, j - 1] * i)% mod;
            }
            var c = new long[n + 1, n + 1];
            c[0, 0] = 1;
            for(int i=1; i <= n; i++)
            {
                c[i, 0] = 1;
                for (int k = 1; k <= i; k++)
                    c[i, k] = (c[i - 1, k - 1] + c[i - 1, k]) % mod;
            }
            var mas = new long[n + 1, x + 1];
            for(int i=1; i <= n; i++)
            {
                for(int j = i; j <= x; j++)
                {
                    if( i == 1)
                    {
                        mas[i, j] = j;
                        continue;
                    }
                    for(int k =0; k < i; k++)
                        mas[i, j] = (mas[i, j] + (((xar[i - 1, k] * c[i, k])%mod) * mas[i - k, j - i + 1])%mod)%mod;
                }
            }
            long xn = 1;
            for (int i = 1; i <= n; i++)
                xn = (xn * x) % mod;
            var res = (xn - mas[n, x] + mod) % mod;
            Console.Write(res);
        }
    }
}

using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class edf116
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(int n) => Enumerable.Repeat(0, n).Select(_ => NList).ToArray();
    static void Main()
    {
        var c = NList;
        var (n, x) = (c[0], c[1]);
        WriteLine(Arena(n, x));
    }
    static long Arena(int n, int x)
    {
        var key = 998244353;
        var ncr = new NCR(Math.Max(n, x), key);
        var exp = new long[n + 1][];
        for (var i = 0; i < exp.Length; ++i)
        {
            exp[i] = new long[n + 1];
            for (var j = 0; j < exp.Length; ++j) exp[i][j] = ncr.Exp(i, j);
        }
        var dp = new long[x][];
        for (var i = 0; i < dp.Length; ++i)
        {
            dp[i] = new long[n];
            dp[i][0] = n;
        }
        for (var i = 0; i < x; ++i) for (var j = 0; j < n; ++j)
        {
            for (var k = j; k < n; ++k)
            {
                if (i + k >= x) break;
                var prev = dp[i + k][k];
                if (j == 0 && k == 0) continue;
                else if (j == k)
                {
                    dp[i + k][k] = (dp[i + k][k] + dp[i][j]) % key;
                }
                else
                {
                    dp[i + k][k] = (dp[i + k][k]
                        + dp[i][j] * ncr.Calc(n - j - 1, k - j) % key * exp[k][k - j] % key) % key;
                }
            }
        }
        var res = 0L;
        for (var i = 0; i < x; ++i) res = (res + dp[i][n - 1]) % key;
        return (ncr.Exp(x, n) + key - res) % key;
    }
    class NCR
    {
        int[] facts;
        int[] revFacts;
        int key;
        public NCR(int n, int key)
        {
            facts = new int[n + 1];
            revFacts = new int[n + 1];
            this.key = key;
            facts[0] = 1;
            var tmp = 1L;
            for (var i = 1; i <= n; ++i)
            {
                tmp = (tmp * i) % key;
                facts[i] = (int)tmp;
            }
            tmp = Exp(facts[n], key - 2);
            revFacts[n] = (int)tmp;
            for (var i = n; i > 1; --i)
            {
                tmp = (tmp * i) % key;
                revFacts[i - 1] = (int)tmp;
            }
        }
        public long Exp(int n, int k)
        {
            if (k == 0) return 1;
            if (k == 1) return n % key;
            var half = Exp(n, k / 2);
            var result = (half * half) % key;
            return ((k % 2) == 0) ? result : ((result * n) % key);
        }
        public int Calc(int n, int r)
        {
            if (r == 0 || r == n) return 1;
            if (r == 1) return n;
            return (int)(((long)facts[n] * revFacts[r] % key) * revFacts[n - r] % key);
        }
        public int Fact(int n)
        {
            return facts[n];
        }
    }
}

using System;
using System.Linq;
using CompLib.Util;
using System.Threading;
using System.IO;
using CompLib.Mathematics;
using System.Collections.Generic;

public class Program
{
    int N, X;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        X = sc.NextInt();

        //int ans = 0;
        //for (int i = 1; i <= 3; i++)
        //{
        //    for (int j = 1; j <= 3; j++)
        //    {
        //        for (int k = 1; k <= 3; k++)
        //        {
        //            int[] h = new int[3] { i, j, k };

        //            if (F(h))
        //            {
        //                ans++;
        //                Console.WriteLine(string.Join(" ", h));
        //            }
        //        }
        //    }
        //}

        //Console.WriteLine(ans);

        var c = new BinomialCoefficient(5000);
        // 残りi人　最大体力j
        var dp = new ModInt[N + 1, X + 1];
        for (int i = 2; i <= N; i++)
        {
            for (int j = 1; j < i && j <= X; j++)
            {
                ModInt tmp = ModInt.Pow(j, i) - ModInt.Pow(j - 1, i);
                dp[i, j] += tmp;
            }
        }

        for (int i = 2; i <= N; i++)
        {
            for (int j = 1; j <= X; j++)
            {
                for (int k = i; k <= N; k++)
                {
                    // k人の状態から (i,j)になった

                    // i人の体力 k-1減る
                    if (j + (k - 1) > X) continue;

                    // k-i人 (k-1)減る
                    dp[k, j + (k - 1)] += dp[i, j] * ModInt.Pow(k - 1, k - i) * c[k, i];
                }
            }
        }

        ModInt ans = 0;
        for (int i = 1; i <= X; i++)
        {
            ans += dp[N, i];
        }
        Console.WriteLine(ans);

        //for (int i = 0; i <= N; i++)
        //{
        //    for (int j = 0; j <= X; j++)
        //    {
        //        Console.Write($"{dp[i, j]} ");
        //    }
        //    Console.WriteLine();
        //}
    }

    bool F(int[] ar)
    {
        if (ar.Length == 0) return true;
        if (ar.Length == 1) return false;
        List<int> ls = new List<int>();
        foreach (int i in ar)
        {
            if (i - ar.Length + 1 > 0)
            {
                ls.Add(i - ar.Length + 1);
            }
        }

        return F(ls.ToArray());
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        // public const long Mod = (int)1e9 + 7;
        public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;
        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n) { num = n; }
        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString() { return num.ToString(); }
        public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
        public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
        public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
        public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1) ret = ret * v % Mod;
            return new ModInt(ret);
        }
        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }
    #endregion
    #region Binomial Coefficient
    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;
        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }
        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }
        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }
    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}