#include <bits/stdc++.h>
using namespace std;
bool okay(int k, pair<int, int> sc[], int m) {
  int c = k;
  vector<int> v;
  while (c > 0) {
    v.push_back(c % 10);
    c /= 10;
  }
  reverse(v.begin(), v.end());
  for (int i = 0; i < m; i++) {
    if (v[sc[i].first] != sc[i].second) {
      return false;
    }
  }
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  pair<int, int> sc[m];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    sc[i] = {x, y};
  }
  int a = pow(10, n - 1), ans = -1;
  for (int i = a; i <= 999; i++) {
    if (okay(i, sc, m)) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}
