#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define endl            '\n'
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e8
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)        substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x)         cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());  

void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(c%2==0)  c=2;
    else c=1;
    
    int val1,val2;
    val1=(int)pow(a,c);
    val2=(int)pow(b,c);
    char ans;
    
    if(val1==val2)
    {
        ans='=';
    }
    else if(val1>val2)
    {
        ans='>';
    }
    
    else
    {
        ans='<';
    }
    
    cout<<ans;
}
 
int32_t main()
{
    FIO;
    // w(t)
        solve();
    return 0;
}

//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int num[8210];
int kazu[8210];
const int ma = (1 << 13) - 1;
int query(int n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 2 % 8209;
	}
	return 0;
}
void add(int n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return;
		n2 = n2 * 2 % 8209;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}
int li[300];

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


	int N, M;
	cin >> N >> M;
	int w[8];
	rep(i, N) cin >> w[i];

	pair<int, int> lv[100001];
	rep(i, M) {
		int l, v;
		cin >> l >> v;
		lv[i] = { v, l };
	}
	sort(lv, lv + M);
	lv[M] = { 1e9,1e9 };

	rep(i, 1 << N) {
		rep(j, N) if (i >> j & 1) li[i] += w[j];
	}
	sort(li, li + (1 << N));
	int saidai = 0;
	int k = 0;
	rep(i, 1 << N) {
		while (lv[k].first < li[i]) {
			if (saidai < lv[k].second) saidai = lv[k].second;
			k++;
		}
		add(li[i], saidai);
	}

	rep(i, N) {
		if (w[i] > lv[0].first) {
			printf("-1");
			return 0;
		}
	}
	int P[8];
	rep(i, N) P[i] = i;

	int kotae = 1e9;
	do {
		int tmp[8] = {};
		rep(p, N - 1) {
			int omosa = w[P[p]];
			for (int q = p + 1; q < N; q++) {
				omosa += w[P[q]];
				int kari = tmp[p] + query(omosa);
				if (tmp[q] < kari) tmp[q] = kari;
			}
		}
		if (kotae > tmp[N - 1]) kotae = tmp[N - 1];
		
	} while (next_permutation(P, P + N));

	printf("%d\n", kotae);

	Would you please return 0;
}