#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
bool vis[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  string ans;
  for (int i = 0; i < n; i++) ans += '0';
  ans[0] = '1';
  map<int, int> mp;
  for (int i = 0; i < m; i++) {
    int x;
    char c;
    cin >> x >> c;
    x--;
    if (mp.find(x) != mp.end() && mp[x] != c) return 0 * puts("-1");
    mp[x] = c;
    ans[x] = c;
  }
  if (ans[0] == '0' && n > 1) return 0 * puts("-1");
  cout << ans << endl;
  return 0;
}
