#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y;
  string s;
  map<int, set<int>> p;
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++) s += '0';
  for (int i = 0; i < (int)(m); i++) {
    cin >> x >> y;
    p[x].insert(y);
    if (p[x].size() > 1) {
      cout << -1;
      return 0;
    } else
      s[x - 1] = y + '0';
  }
  if (n != 1) {
    if (m == 0)
      s[0] = '1';
    else if (s[0] == '0')
      s[0] = '1';
  }
  cout << s;
}
