#include <bits/stdc++.h>
using namespace std;
long long n, m, z, x, s, a[5], c[5];
int main() {
  cin >> n;
  cin >> m;
  int ff = 0;
  long long ans = 0;
  if (m == 0) {
    if (n > 1) {
      cout << 1;
      for (int i = 2; i <= n; i++) cout << 0;
    } else
      cout << 0;
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    cin >> z >> x;
    if (a[z] == 0 && c[z] == 0) {
      c[z]++;
      a[z] = x;
    } else if (c[z] == 1 && a[z] != x)
      ans = -1;
  }
  if (ans == -1 || (a[1] == 0 && c[1] >= 1 && n > 1))
    cout << -1 << "\n";
  else {
    if (n == 1)
      cout << 0;
    else {
      if (a[1] == 0) {
        cout << 1;
        for (int i = 2; i <= n; i++) cout << a[i];
      } else {
        for (int i = 1; i <= n; i++) cout << a[i];
      }
    }
  }
}
