#include <bits/stdc++.h>
using namespace std;
const long long MAX = 200001;
const long long MOD = 1000000007;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long x[n];
  for (long long i = 0; i < n; i++) x[i] = -1;
  long long s, c;
  for (long long i = 0; i < m; i++) {
    cin >> s >> c;
    s--;
    if (x[s] != -1 && x[s] != c) {
      cout << -1;
      return 0;
    }
    x[s] = c;
  }
  if (x[0] == 0) {
    if (n != 1)
      cout << -1;
    else
      cout << 0;
    return 0;
  }
  if (x[0] == -1) x[0] = 1;
  for (long long i = 1; i < n; i++)
    if (x[i] == -1) x[i] = 0;
  for (long long i = 0; i < n; i++) cout << x[i];
}
