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