#include <bits/stdc++.h>
using namespace std;
int n, m, s, c;
string a;
bool ok = 1;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> m;
  a = "XXX";
  while (m--) {
    cin >> s >> c;
    if (a[s - 1] != 'X' && a[s - 1] != char(c + 48)) {
      ok = 0;
    }
    a[s - 1] = char(c + 48);
  }
  if (a[0] == '0') ok = 0;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == 'X') a[i] = '1';
  }
  if (ok)
    cout << a;
  else
    cout << -1;
}
