#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> d(n, -1);
  for (int i = 0; i < (int)m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (d[s] == -1 || d[s] == c)
      d[s] = c;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < (int)n; i++) {
    int x = d[i];
    if (x == -1) {
      if (i == 0)
        x = 1;
      else
        x = 0;
    }
    cout << x;
  }
  cout << endl;
}
