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