#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  for (int i = 0; i < (m); i++) {
    int s, c;
    cin >> s >> c;
    if (ans[s - 1] == -1 || ans[s - 1] == c) {
      ans[s - 1] = c;
    } else {
      puts("-1");
      return 0;
    }
  }
  if (ans[0] == 0) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < (n); i++) {
    if (ans[i] == -1) {
      cout << (i == 0 ? 1 : 0);
    } else {
      cout << ans[i];
    }
  }
  cout << endl;
}
