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