#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> vis, vis1;
  int num[n];
  for (int i = 0; i < n; ++i) num[i] = 0;
  int fn(0);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if (a > n) fn = 1;
    if (vis1[a] && vis[a] != b) fn = 1;
    if (a == 1 && b == 0) fn = 1;
    vis[a] = b;
    vis1[a] = 1;
    num[a - 1] = b;
  }
  if (fn == 1)
    cout << -1;
  else {
    if (m == 0 && n > 1) num[0] = 1;
    if (num[0] == 0) num[0] = 1;
    for (int i = 0; i < n; ++i) cout << num[i];
  }
}
