#include <bits/stdc++.h>
using namespace std;
long long int N, M, A, B, C;
long long int arr[15], arr1[15];
vector<long long int> V;
long long int ans[15];
int main() {
  scanf("%lld %lld", &N, &M);
  ans[1] = 1;
  for (int i = 0; i < M; i++) {
    scanf("%lld %lld", &arr[i], &arr1[i]);
    if (ans[arr[i]] != arr1[i] && ans[arr[i]] != 0 && arr[i] != 1) {
      printf("-1\n");
      exit(0);
    }
    if (arr[i] == 1 && arr1[i] == 0) {
      printf("-1\n");
      exit(0);
    }
    ans[arr[i]] = arr1[i];
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i];
  }
  return 0;
}
