#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;
const ll K_MAX = 1e5 + 5;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) a[i] = -1;
  for (int i = 0; i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    --s;
    if (n > 1 && s == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (a[s] == -1 || a[s] == c) {
      a[s] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < (n); ++i) {
    if (i == 0 && a[i] == -1)
      a[0] = 1;
    else if (a[i] == -1)
      a[i] = 0;
    cout << a[i];
  }
  return 0;
}
