#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int> mem(n, -1);
  vector<pair<int, int>> sc(m);
  for (int i = 0; i < m; i++) cin >> sc[i].first >> sc[i].second;
  for (int i = 0; i < 1000; i++) {
    string str = to_string(i);
    if (str.size() != n) continue;
    bool flag = true;
    for (int j = 0; j < m; j++) {
      if (str[sc[j].first - 1] != sc[j].second) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << str << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
