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