#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const long long int ths = 1LL << 40;
const int NN = 5e3 + 6;
void solve() {
  long long int n, m;
  cin >> n >> m;
  string s;
  for (int i = 0; i < n; i++) s += '0';
  long long int XX[3];
  XX[0] = XX[1] = XX[2] = -1;
  bool ok = 1;
  while (m--) {
    long long int idx, val;
    cin >> idx >> val;
    idx--;
    if (XX[idx] != -1 && XX[idx] != val) ok = 0;
    s[idx] = '0' + val;
    if (XX[idx] == -1) XX[idx] = val;
  }
  if (ok == 0 || XX[0] == 0) {
    cout << -1;
    return;
  }
  if (s[0] == '0') s[0] = '1';
  cout << s;
  cout << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
