#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  int ten = 1;
  map<int, int> mp;
  for (int i = 0; i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    mp[s] = c;
  }
  for (auto P : mp) {
    int S = P.first;
    int C = P.second;
    int loop = n - S;
    for (int j = 0; j < (loop); ++j) ten *= 10;
    ans += P.second * ten;
    ten = 1;
  }
  int digit = 0;
  int tmp = ans;
  while (tmp > 0) {
    tmp /= 10;
    digit++;
  }
  if (digit != n) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
