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