#include <bits/stdc++.h>
using namespace std;
void solve_main() {
  int n, m;
  cin >> n >> m;
  int num[n + 1];
  memset(num, -1, sizeof(num));
  while (m--) {
    int i, v;
    cin >> i >> v;
    if (num[i] == -1) {
      num[i] = v;
      continue;
    }
    if (num[i] == v) continue;
    cout << "-1\n";
    return;
  }
  if (num[1] == -1) num[1] = 1;
  if (num[1] == 0) {
    if (n == 1)
      cout << "0";
    else
      cout << "-1";
    return;
  }
  for (int i = 1; i <= n; i += 1) {
    if (num[i] == -1) num[i] = 0;
    cout << num[i];
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve_main();
  }
}
