#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> num(N, -1);
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (num[s] == -1 || num[s] == c)
      num[s] = c;
    else {
      cout << -1;
      return 0;
    }
  }
  if (N == 1)
    cout << num[0];
  else if (num[0] != 0) {
    if (num[0] == -1) num[0] = 1;
    for (int& x : num)
      if (x == -1) x = 0;
    for (int x : num) printf("%1d", x);
  } else
    cout << -1;
}
