#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i;
  cin >> n >> m;
  int arr[m][1];
  memset(arr, 0, sizeof(arr));
  int lower = 1;
  for (i = 1; i < n; i++) lower *= 10;
  int upper = lower * 10 - 1;
  for (i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    arr[a - 1][0] = b;
  }
  int sum = 0;
  for (i = 0; i < m; i++) sum = sum * 10 + arr[i][0];
  int found = 0;
  for (i = lower; i <= upper; i++) {
    if (sum == i) {
      found = 1;
      break;
    }
  }
  if (found)
    cout << i;
  else
    cout << "-1";
  return 0;
}
