#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  vector<int> ans(N, -1);
  bool can = 1;
  for (int(i) = 0; (i) < (M); (i)++) {
    int s, c;
    cin >> s >> c;
    if (ans[s - 1] == -1) {
      ans[s - 1] = c;
    } else if (ans[s - 1] != c) {
      can = 0;
    }
  }
  if (N != 1 && ans[0] == 0) can = 0;
  for (int(i) = 0; (i) < (N); (i)++) {
    if (ans[i] == -1) {
      if (i == 0)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  if (!can)
    cout << "-1" << endl;
  else {
    for (int(i) = 0; (i) < (N); (i)++) cout << ans[i];
    cout << endl;
  }
  return 0;
}
