#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int arr[N];
  memset(arr, 0, N);
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    arr[s - 1] = c;
  }
  if (arr[0] == 0 && N > 1)
    cout << -1;
  else {
    for (int i = 0; i < N; i++) cout << arr[i];
  }
  cout << '\n';
  return 0;
}
