#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  bool ok = 1;
  for (int i = 0; i < m; i++) {
    int pos, tmp;
    cin >> pos >> tmp;
    if (mp.find(pos) != mp.end() && mp[pos] != tmp) ok = 0;
    if (pos == 1 && tmp == 0) ok = 0;
    mp[pos] = tmp;
  }
  if (!ok)
    cout << -1;
  else {
    for (int i = 1; i <= n; i++) cout << (mp.find(i) != mp.end() ? mp[i] : 1);
  }
  return 0;
}
