#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, d[5];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) d[i] = -1;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if ((d[s] != -1 && d[s] != c) || (s == 1 && c == 0)) {
      cout << "-1\n";
      return 0;
    }
    d[s] = c;
  }
  cout << max(d[1], 1);
  for (int i = 2; i <= n; i++) cout << max(d[i], 0);
  cout << "\n";
  return 0;
}
