#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int dig_orig = 1;
  for (int i = 0; i < (n); ++i) {
    dig_orig *= 10;
  }
  string ans = "000";
  for (int i = 0; i < (m); ++i) {
    int num, digits;
    cin >> digits >> num;
    ans[digits - 1] = num + '0';
    cout << ans << endl;
  }
  int res;
  if (ans == "000") {
    res = 0;
  }
  if (stoi(ans) < dig_orig && stoi(ans) >= dig_orig / 10) {
    res = stoi(ans);
  } else {
    res = -1;
  }
  cout << res << endl;
}
