#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  pair<int, int> p[m];
  for (int i = 0; i < m; ++i) cin >> p[i].first >> p[i].second;
  sort(p, p + m);
  for (int i = 0; i < m - 1; ++i) {
    if (p[i].first == p[i + 1].first && p[i].second != p[i + 1].second) {
      cout << (-1) << "\n";
      return 0;
    }
  }
  bool flag[n + 1];
  for (int i = 0; i < n + 1; ++i) flag[i] = false;
  char c[n + 1];
  for (int i = 0; i < n + 1; ++i) c[i] = '0';
  for (int i = 0; i < m; ++i) {
    c[p[i].first] = '0' + p[i].second;
    flag[p[i].first] = true;
  }
  if (flag[1] == true && c[1] == '0') {
    cout << (-1) << "\n";
    return 0;
  } else
    c[1] = '1';
  for (int i = 1; i <= n; ++i) {
    printf("%c", c[i]);
  }
  printf("\n");
}
