#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s, c;
  cin >> n >> m;
  int str[n];
  bool flag = true;
  for (int i = 0; i < (n); i++) str[i] = -1;
  for (int i = 0; i < (m); i++) {
    cin >> s >> c;
    if (str[s - 1] != -1 && str[s - 1] != c) {
      flag = false;
      break;
    }
    str[s - 1] = c;
  }
  if (n > 1 && str[0] == 0) flag = false;
  for (int i = 0; i < (n); i++) {
    if (str[i] == -1) {
      if (i == 0)
        str[i] = 1;
      else
        str[i] = 0;
    }
  }
  if (flag) {
    for (int i = 0; i < (n); i++) cout << str[i];
    cout << endl;
  } else
    cout << -1 << endl;
  return 0;
}
