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