#include <bits/stdc++.h>
using namespace std;
int n, m, a[10], b[10];
int s, c;
int main() {
  while (cin >> n >> m) {
    for (int i = 1; i <= 5; i++) a[i] = -1;
    for (int i = 1; i <= m; i++) {
      cin >> s >> c;
      if (a[s] != -1 && a[s] != c) n = -1;
      a[s] = c;
    }
    if (n == -1) {
      cout << -1 << endl;
      return 0;
    }
    if (a[1] == -1) a[1] = 1;
    for (int i = 1; i <= n; i++) {
      if (a[i] == -1) a[i] = 0;
      cout << a[i];
    }
    cout << endl;
  }
}
