#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int a[3];
int main() {
  int n, m;
  bool flag = true;
  cin >> n >> m;
  fill(a, a + 3, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      flag = false;
      break;
    } else if (a[s] != -1 && a[s] != c) {
      flag = false;
      break;
    } else {
      a[s] = c;
    }
  }
  if (!flag)
    cout << -1 << "\n";
  else {
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) {
        if (i == 0)
          cout << 1;
        else
          cout << 0;
      } else
        cout << a[i];
    }
    cout << "\n";
  }
}
