#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n + 1, -1);
  ans[0] = 1;
  while (m--) {
    int s, c;
    cin >> s >> c;
    if (ans[s] != -1) {
      ans[0] = -1;
      continue;
    }
    ans[s] = c;
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] == -1) {
      if (i == 1) {
        ans[i] = 1;
      } else {
        ans[i] = 0;
      }
    }
  }
  if (ans[0] == -1 || ans[1] == 0) {
    cout << "-1";
  } else {
    for (int i = 1; i <= n; i++) {
      cout << ans[i];
    }
  }
}
