#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int idx = 0, dig = 0, in = 0, num = 0;
  int ans[3] = {-1, -1, -1};
  cin >> dig >> in;
  if (in == 0) {
    if (dig > 1) {
      cout << 1;
      dig--;
    }
    while (dig-- > 0) cout << 0;
    return (0);
  }
  while (in-- > 0) {
    cin >> idx >> num;
    if ((ans[idx - 1] != -1 && ans[idx - 1] != num) ||
        (dig > 1 && idx == 1 && num == 0)) {
      cout << -1 << endl;
      return (0);
    }
    ans[idx - 1] = num;
  }
  for (int i = 0; i < dig; i++) {
    if (ans[i] == -1 && i == dig - 1)
      cout << 1;
    else if (ans[i] == -1)
      cout << 0;
    else
      cout << ans[i];
  }
  cout << endl;
  return (0);
}
