#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 6;
int arr[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n];
  memset(arr, 0, sizeof(arr));
  while (m--) {
    int a, b;
    cin >> a >> b;
    arr[a - 1] = b;
  }
  int lead = 1;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0 and lead) {
      cout << -1 << endl;
      break;
    } else {
      cout << arr[i];
      lead = 0;
    }
  }
}
