#include <bits/stdc++.h>
using namespace std;
int IsUnCommand(vector<pair<int, int>>::iterator begin,
                vector<pair<int, int>>::iterator end, pair<int, int> input) {
  for (; begin != end; begin++) {
    if (begin->first == input.first && begin->second != input.second) {
      return 0;
    }
    if (begin->first == input.first && begin->second == input.second) {
      return 2;
    }
  }
  return 1;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> command;
  for (int i = 1; i <= M; i++) {
    pair<int, int> input;
    cin >> input.first;
    cin >> input.second;
    if (input.first == 1 && input.second == 0 && N > 1) {
      cout << "-1" << endl;
      exit(0);
    }
    switch (IsUnCommand(command.begin(), command.end(), input)) {
      case 0:
        cout << "-1" << endl;
        exit(0);
        break;
      case 1:
        command.push_back(input);
        break;
    }
  }
  sort(command.begin(), command.end());
  int num = 0;
  for (int i = 1; i <= N; i++) {
    if (command[num].first == i) {
      cout << command[num].second;
      if (num < command.size() - 1) {
        num++;
      }
    } else if (i == 1) {
      cout << "1";
    } else {
      cout << "0";
    }
  }
  cout << endl;
  return 0;
}
