#include <bits/stdc++.h>
using namespace std;
long long int ara[4], mark[15];
int main() {
  memset(ara, -1, sizeof(ara));
  int n, m, a, b, ok = 1;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (ara[a] != -1 && b != ara[a]) {
      ok = 0;
    }
    ara[a] = b;
  }
  for (int i = 1; i <= n; i++) {
    if (i == 1 && ara[i] == -1)
      ara[i] = 1;
    else if (ara[i] == -1 && i != 1)
      ara[i] = 0;
  }
  if (ara[1] == 0 && n > 1 || ara[1] == -1) ok = 0;
  if (ok)
    for (int i = 1; i <= n; i++) cout << ara[i];
  else
    cout << "-1" << endl;
  return 0;
}
