#include <bits/stdc++.h>
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s, c;
  bool able = true;
  int n[N];
  for (int i = 0; i < N; i++) {
    n[i] = -1;
  }
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    if (s == 1 && c == 0) {
      able = false;
      break;
    }
    if (n[s - 1] != c && n[s - 1] >= 0) {
      able = false;
      break;
    }
    n[s - 1] = c;
  }
  if (n[0] == 10) {
    n[0] = 1;
  }
  if (able) {
    for (int i = 0; i < N; i++) {
      cout << max(n[i], 0);
    }
    cout << endl;
  } else {
    cout << "-1" << endl;
  }
}
