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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, m; cin >> n >> m;
	vector<int> a(m), b(m), c(n);
	vector<vector<pair<int, int>>> g(n);
	FOR(i, 0, m){
		cin >> a[i] >> b[i];
		--a[i]; --b[i];
		g[a[i]].PB({b[i], i});
		g[b[i]].PB({a[i], i});
	}
		
	FOR(i, 0, n) cin >> c[i];
	
	auto finalize = [&](vector<int>& ans){
		FOR(i, 0, m){
			cout << (ans[i] ? "<-\n" : "->\n");
		}
		exit(0);
	};	

	
	set<PII> S;
	FOR(i, 0, n) S.insert({c[i], i});

	vector<int> ans(m, -1);
	vector<int> alive(n, 1);
	
	while(SZ(S)){
		int v = S.begin()->Y;
		set<int> used;
		
		function<void(int)> dfs = [&](int u){
			used.insert(u);
			for(auto to: g[u]){
				if (c[to.X] == c[v]){
					if (ans[to.Y] == -1){					
						ans[to.Y] = a[to.Y] == u ? 0 : 1;//vid u
					}
					
					if (!used.count(to.X)){
						dfs(to.X);
					}
				}
			}
		};

		dfs(v);
		//assert(SZ(used) == c[v]);
		
		for(auto u: used){
			S.erase({c[u], u});
			alive[u] = 0;
		}

		for(auto u: used){
			for(auto to: g[u]){
				if (alive[to.X]){
					ans[to.Y] = a[to.Y] == u ? 1 : 0;
				}
			}
		}
	}
	
	finalize(ans);
	
    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;
 
int main() {
    ll n, k;
    cin >> n >> k;
    
    vvl dp(n+1, vl(2*n + 1));  // dp[i][j] : 要素数iで総和がjとなる場合の数
    dp[0][0] = 1;
    exrep(i, 1, n) {
        for(ll j = n; j >= 1; j--) {
            if(i >= j) {
                dp[i][j] = (dp[i-1][j-1] + dp[i][2*j]) % mod;
            }
        }
    }

    out(dp[n][k]);
    re0;
}