#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
  int n, m;
  cin >> n >> m;
  int s, t;
  int f = 1;
  memset(a, -1, sizeof(a));
  if (m == 0) {
    cout << "1";
    for (int i = 2; i <= n; i++) cout << "0";
    cout << endl;
  } else {
    for (int i = 0; i < m; i++) {
      cin >> s >> t;
      if (a[s] == -1 || a[s] == t)
        a[s] = t;
      else
        f = 0;
    }
    if ((n != 1 && a[1] == 0) || f == 0)
      cout << "-1" << endl;
    else {
      for (int i = 1; i <= n; i++) {
        if (a[i] == -1 && i == 1) cout << "1";
        if (a[i] == -1)
          cout << "0";
        else
          cout << a[i];
      }
      cout << endl;
    }
  }
  return 0;
}
