#include <bits/stdc++.h>
using namespace std;
int num[4], n, m;
int main() {
  memset(num, -1, sizeof(num));
  cin >> n >> m;
  while (m--) {
    int s, c;
    cin >> s >> c;
    if (num[s] == -1)
      num[s] = c;
    else if (num[s] != c) {
      cout << -1;
      return 0;
    }
  }
  if (n != 0 and num[1] == 0) {
    cout << -1;
    return 0;
  }
  if (num[1] == -1) num[0] = 1;
  for (int i = 2; i <= n; i++)
    if (num[i] == -1) num[i] = 0;
  for (int i = 1; i <= n; i++) {
    cout << num[i];
  }
}
