#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int c[n], s, ct;
  if (n == 1) c[0] = 0;
  if (n >= 2) {
    c[0] = 1;
    c[1] = 0;
  }
  if (n >= 3) c[2] = 0;
  bool f = true;
  for (int i = 0; i < m; i++) {
    cin >> s >> ct;
    if (s == 1) {
      if (n == 1 && (c[0] != 0 && c[0] != ct)) f = false;
      if (n >= 2 && (c[0] != 1 & c[0] != ct))
        f = false;
      else
        c[0] = ct;
    } else {
      if (c[s - 1] != ct && c[s - 1] != 0)
        f = false;
      else
        c[s - 1] = ct;
    }
  }
  if (f)
    for (int i = 0; i < n; i++) cout << c[i];
  else
    cout << -1;
  return 0;
}
