#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int map[n + 1];
  memset(map, -1, sizeof(map));
  for (int i = 0, s, c; i < m; i++) {
    cin >> s >> c;
    if ((map[s] != -1 && map[s] != c) || (s == 1 && c == 0)) {
      cout << -1 << '\n';
      return 0;
    }
    map[s] = c;
  }
  for (int i = 1; i <= n; i++) {
    if (map[i] != -1)
      cout << map[i];
    else
      cout << ((i != 1 || n == 1) ? 0 : 1);
  }
  cout << '\n';
  return 0;
}
