#include <bits/stdc++.h>
using namespace std;
int g[15][15];
const int INF = 1001001001;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
vector<pair<long long, int>> factorize(long long n) {
  vector<pair<long long, int>> res;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}
int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < m; ++i) {
    cin >> s[i] >> c[i];
  }
  int ans = -1;
  for (int i = 0; i < 1000; ++i) {
    string S = to_string(i);
    bool flag = true;
    int keta = 1;
    int res = i / 10;
    while (res > 0) {
      res /= 10;
      keta++;
    }
    if (keta != n) continue;
    for (int j = 0; j < m; ++j) {
      if (S[s[j] - 1] != 'c[j]') flag = false;
    }
    if (flag) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
