#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  bool shit = 0;
  for (int i = 0; i < m; ++i) {
    int s, x;
    cin >> s >> x;
    --s;
    if (a[s] != -1 && a[s] != x)
      shit = 1;
    else
      a[s] = x;
  }
  if (a[0] == 0) shit = 1;
  if (shit)
    cout << "-1\n";
  else {
    for (int i = 0; i < n; ++i) {
      if (a[i] == -1) {
        if (i)
          cout << '0';
        else
          cout << '1';
      } else
        cout << a[i];
    }
    cout << '\n';
  }
}
