#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
inline int cmp(double x, double y = 0) {
  if (fabs(x - y) < EPS) return 0;
  return x > y ? 1 : -1;
}
const int maxn = 6;
int s[maxn], c[maxn];
int poww(int a, int b) {
  int ans = 1;
  while (b--) {
    ans *= a;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (int i = poww(10, n - 1); i < poww(10, (n)); i++) {
    string t = to_string(i);
    bool ok = true;
    for (int j = 0; j < m; j++) {
      ok &= t[s[j]] == c[j] + '0';
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
