#include <bits/stdc++.h>
using namespace std;
long long int power(long long int base, long long int val) {
  long long int res = 1;
  while (val) {
    if (val & 1) {
      res = (res * base) % 1000000007;
    }
    base = (base * base) % 1000000007;
    val /= 2;
  }
  return res;
}
long long int digit(long long int n) {
  double phi = (1 + sqrt(5)) / 2;
  long long int value = round(pow(phi, n) / (sqrt(5)));
  long long int count = 0;
  while (value) {
    count++;
    value /= 10;
  }
  return count;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> arr(n + 1, -1);
  bool game = true;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (arr[a] == -1) {
      arr[a] = b;
    } else if (arr[a] != b) {
      game = false;
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == -1 && i != 1)
      arr[i] = 0;
    else if (arr[i] == -1 && i == 1)
      arr[i] = 1;
    else if (arr[i] == 0 && i == 1 && n != 1) {
      game = false;
      break;
    }
  }
  if (game) {
    for (int i = 1; i <= n; i++) cout << arr[i];
  } else
    cout << -1 << '\n';
}
