#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(m, vector<int>(2, 0));
  for (int i = 0; i < m; i++) {
    cin >> v[i][0] >> v[i][1];
  }
  if (m == 0) {
    if (n == 1) {
      cout << 0 << endl;
    } else {
      cout << pow(10, n - 1) << endl;
    }
  } else {
    for (int i = pow(10, n - 1); i < pow(10, n); i++) {
      string s = to_string(i);
      bool f = true;
      for (int j = 0; j < m; j++) {
        if (s[v[j][0] - 1] != v[j][1] + 48) {
          f = false;
          break;
        }
      }
      if (f) {
        cout << i << endl;
        break;
      }
      if (f == false && i == pow(10, n) - 1) {
        cout << -1 << endl;
      }
    }
  }
}
