#include <bits/stdc++.h>
using namespace std;
long double PI = 3.14159265358979323846;
const long long M = 1e9 + 7;
const long long inf = 1e18;
const long long ms = 2e5 + 5;
static int fastline = []() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  return 0;
}();
;
long long ans, n, m;
void solve() {
  cin >> n >> m;
  string s = "1";
  map<int, int> mp;
  for (int i = 1; i < n; i++) s += "0";
  bool flag = 0;
  for (int i = 0; i < m; i++) {
    long long ind, var;
    cin >> ind >> var;
    if (n > 1 && ind == 1 && var == 0) {
      flag = 1;
      break;
    }
    if (mp.find(ind) != mp.end() && mp[ind] < var) {
      flag = 1;
      break;
    }
    mp[ind] = var;
    s[ind - 1] = var + '0';
  }
  if (flag)
    cout << -1 << endl;
  else
    cout << s << endl;
}
int main() {
  { solve(); }
  return 0;
}
