#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long* s = new long long[m];
  long long* c = new long long[m];
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  long long all_num = 1;
  for (int i = 0; i < n; i++) {
    all_num *= 10;
  }
  string* nums = new string[all_num];
  string temp = "000";
  for (int i = 0; i < all_num; i++) {
    nums[i].resize(n);
    nums[i] = temp;
    temp[2]++;
    if (temp[2] == '9' + 1) {
      temp[1]++;
      temp[2] = '0';
      if (temp[1] == '9' + 1) {
        temp[0]++;
        temp[1] = '0';
      }
    }
  }
  string result = "-1";
  for (int i = 0; i < all_num; i++) {
    bool flag2 = true;
    for (int j = 0; j < m; j++) {
      if (nums[i][s[j] - 1] - '0' != c[j]) {
        flag2 = false;
      }
    }
    if (flag2) {
      result = nums[i];
      break;
    }
  }
  cout << stoi(result);
  return 0;
}
