#include <bits/stdc++.h>
using namespace std;
struct node {
  int sh, val;
} a[305];
int main() {
  int n, s;
  cin >> n >> s;
  int shwei[n + 1];
  shwei[1] = 1;
  for (int i = 1; i <= s; i++) {
    cin >> a[i].sh >> a[i].val;
  }
  for (int i = 2; i <= n; i++) shwei[i] = 0;
  for (int i = 1; i <= s; i++) {
    for (int j = i; j <= s; j++) {
      if (a[i].sh == a[j].sh && a[i].val != a[j].val) {
        cout << -1;
        return 0;
      }
      if (a[i].sh == 1 && a[i].val == 0) {
        cout << -1;
        return 0;
      }
    }
  }
  for (int i = 1; i <= s; i++) {
    shwei[a[i].sh] = a[i].val;
  }
  for (int i = 1; i <= n; i++) {
    cout << shwei[i];
  }
  return 0;
}
