#include <bits/stdc++.h>
using namespace std;
void solve(int test_case) {
  int n, m;
  cin >> n >> m;
  vector<int> arr(n, 0);
  while (m-- > 0) {
    int a, b;
    cin >> a >> b;
    if ((a == 1 && b == 0) || (arr[a - 1] != 0 && arr[a - 1] != b) || a > n) {
      cout << -1;
      return;
    }
    arr[a - 1] = b;
  }
  if (arr[0] == 0 && n > 1) arr[0] = 1;
  for (int i = 0; i < n; i++) cout << arr[i];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
  return 0;
}
