#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  string number;
  for (int i = 0; i < N; i++)
    if (i == 0)
      number.push_back('1');
    else
      number.push_back('0');
  vector<int> clear(N, -1);
  for (int i = 0; i < M; i++) {
    int digit, num;
    cin >> digit >> num;
    if (clear[digit - 1] != num && clear[digit - 1] != -1) {
      cout << -1 << endl;
      return 0;
    } else {
      clear[digit - 1] = num;
    }
    number[digit - 1] = static_cast<char>(num + 48);
  }
  if (number.size() > 1 && number[0] == '0')
    cout << -1 << endl;
  else
    cout << number << endl;
};
