#include <bits/stdc++.h>
using namespace std;
int char_num(char a[], int N) {
  int num = 0;
  int pop = 1;
  for (int i = N; i != 0; --i) {
    num += (a[i - 1] - '0') * pop;
    pop *= 10;
  }
  return num;
}
int main() {
  int N, M;
  cin >> N >> M;
  char num[N];
  for (int i = 0; i != N; ++i) {
    num[i] = '0';
  }
  int s;
  char c;
  for (int i = 0; i != M; ++i) {
    cin >> s;
    cin >> c;
    num[s - 1] = c;
  }
  if (num[0] == '0')
    cout << -1 << endl;
  else
    cout << char_num(num, N) << endl;
}
