#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int s[7];
int c[7];
int d[7];
int ss;
int ans;
int main() {
  cin >> n >> m;
  for (int i = (0); (i) < (7); (i)++) d[i] = -1;
  for (int i = (0); (i) < (m); (i)++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (int i = (0); (i) < (m); (i)++) {
    ss = s[i];
    if (d[ss] == -1) {
      d[ss] = c[i];
    } else {
      if (d[ss] != c[i]) ans = -1;
    }
  }
  for (int i = (0); (i) < (n); (i)++) {
    if (d[i] == -1) {
      if (i == 0)
        d[i] = 1;
      else
        d[i] = 0;
    }
  }
  if (d[0] == 0) ans = -1;
  if (ans == -1) {
    cout << ans << endl;
  } else {
    for (int i = (0); (i) < (n); (i)++) cout << d[i];
    cout << endl;
  }
  return 0;
}
