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