#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n + 1];
  for (int i = 0; i <= n; i++) arr[i] = 0;
  arr[1] = 1;
  if (m == 0) {
    cout << pow(10, n - 1) << '\n';
    return 0;
  }
  int S[m], C[m];
  for (int i = 0; i < m; i++) {
    cin >> S[i] >> C[i];
    arr[S[i]] = C[i];
  }
  bool sol = true;
  for (int i = 0; i < m; i++) {
    if (arr[S[i]] != C[i]) sol = false;
  }
  if (arr[1] == 0 && n > 1) sol = false;
  if (sol) {
    for (int i = 1; i <= n; i++) cout << arr[i];
    cout << '\n';
  } else
    cout << -1 << '\n';
  return 0;
}
