#include <bits/stdc++.h>

using namespace std;

//0~nの範囲操作
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//1~nの範囲操作
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
//n~0を後ろから範囲操作
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
//出力後改行を
#define fin(ans) cout << (ans) << endl;
//出力後空白を
#define blank(ans) cout << (ans) << " ";
//２つの値をセットに\
sort -> p -> q
#define mp(p, q) make_pair(p, q)
//３つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
//配列の末尾にnを追加
#define pb(n) push_back(n)
//配列の末尾を削除1
#define cb(n) pop_back(n)
//配列全操作
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 100000007;

//配列の合計
template <typename T>
T Sum(vector<T> n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}
//少数時
template <>
ld Sum(vector<ld> n, ll a, ll b)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0.));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0.));
  }
}

//配列を昇順ソート
template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

//配列を降順ソート
template <typename T>
void Down(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end(), greater<ll>()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b, greater<ll>()));
  }
}

//配列を反転
template <typename T>
void Reve(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (reverse(n.begin() + a, n.end()));
  }
  else
  {
    return (reverse(n.begin() + a, n.begin() + b));
  }
}

//配列nをmにコピー
template <typename T, typename U>
void Copy(T &n, U &m, ll a = 0, ll b = 0)
{
  copy(all(n), m.begin());
}

//配列入力
template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

//２列配列入力
template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

//３列配列入力
template <typename T, typename U, typename W>
void V3(T &n, U &m, W &p)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i] >> p[i];
  }
}

//２重配列入力
template <typename T>
void VV(T &n, ll size)
{
  for (ll i = 0; i < n.size(); i++)
  {
    for (ll j = 0; j < size; j++)
    {
      cin >> n[i][j];
    }
  }
}

//９０度回転
template <typename T>
void Rool(T &n, T &m, ll height, ll width)
{
  for (ll i = 0; i < width; i++)
  {
    for (ll j = 0; j < height; j++)
    {
      m[i][j] = n[height - j - 1][i];
    }
  }
}

//Yes, Noと表示後終了
void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}

//四捨五入
ll C45(ld n)
{
  return round(n);
}

//切り上げ (a / b)時
ll Up(ll a, ll b)
{
  return ((a + b - 1) / b);
}

//素数
bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//各桁の和
ll KSum(ll n)
{
  ll sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(ll n)
{
  ll reverse = 0;
  ll remaind;
  ll tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//最大公約数
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

//複数個の最大公約数
ll ngcd(vector<ll> a)
{
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size() && res != 1; i++)
  {
    res = gcd(a[i], res);
  }
  return res;
}

//最小公倍数
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

//複数個の最小公倍数
ll nlcm(vector<ll> numbers)
{
  ll res;
  res = numbers[0];
  for (ll i = 1; i < numbers.size(); i++)
  {
    res = lcm(res, numbers[i]);
  }
  return res;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//逆数(aの逆数)
ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

//階乗
ll factorial(ll n, ll mod = MOD)
{
  if (n > 0)
    return n * factorial(n - 1) % mod;
  else
    return 1;
}

//順列 nPr
ll perm(ll a, ll b)
{
  return (factorial(a) / factorial(a - b));
}

//組み合わせ　nCr
ll comb(ll a, ll b)
{
  return (factorial(a) / (factorial(a - b) * factorial(b)));
}

//組み合わせ　nCr % mod
ll fac[500000], finv[500000], inv[500000];
// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// 二項係数計算
ll COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//組み合わせの数を返す
ll cnt = 0;
ll func(vector<char> list, ll len, ll index)
{
  //列を格納するvector、列の長さ、インデックス番号
  // インデックス番号の文字をインデックス番号から右側の文字だけを交換してゆく

  // indexが末尾から2番目になったら末尾の二つだけを交換してそれぞれを表示する
  if (index >= len - 2)
  {
    for (ll i = 0; i < len; i++)
      cout << list[i]; // 交換する前の列を表示する
    cout << endl;

    swap(list[len - 1], list[len - 2]); //末尾の二つを交換する

    for (ll i = 0; i < len; i++)
      cout << list[i]; // 交換した後の列を表示する
    cout << endl;

    cnt += 2; // cntで組み合わせ数をカウントする
    return 0;
  }

  vector<char> list2 = list;
  func(list, len, index + 1); // index番号の文字がindex番目（つまり移動していな状態）にある列を
                              //次の再帰関数に渡す

  for (ll i = index + 1; i < len; i++)
  {
    swap(list[index], list[i]); // index番目とi番目を交換する
    func(list, len, index + 1); // 交換処理した列を次の再帰関数に渡す。index値は＋１しておく
    list = list2;
  }

  return 0;
}

//n ~ mの和
ll sigma(ll n, ll m)
{
  return ((n + m) * (m - n + 1) * 0.5);
}

//期待値
ld hope(ld a)
{
  return (sigma(1, a) / a);
}

//階乗
ll modfactorial(ll n, ll mod = MOD)
{
  ll ans = 1;
  rep(i, n)
  {
    ans *= (i + 1);
    ans %= mod;
  }
  return ans;
}

void Main()
{
  ll n, m; cin >> n >> m;
  vll s(m), c(m); V2(s, c);
  vll ans(n, -1);
  for(ll i = 0;i < m;i++)
  {
    if(s[i] == 1&&ans[0] == -1)
    {
      ans[0] = c[i];
      if(n != 1&&c[i] == 0)
      {
        cout << -1;
        exit(0);
      }
    }
    else if(s[i] == 1&&ans[0] != c[i])
    {
      cout <<-1;exit(0);
    }

    if(s[i] == 2&&ans[1] == -1)
    {
      ans[1] = c[i];
    }
    else if(s[i] == 2&&ans[1] != c[i])
    {
      cout <<-1;exit(0);
    }
    
    if(s[i] == 3&&ans[2] == -1)
    {
      ans[2] = c[i];
    }
    else if(s[i] == 3&&ans[2] != c[i])
    {
      cout <<-1;exit(0);
    }
  }
  for(ll i = 0;i < n;i++)
  {
    if(ans[i] == -1)
    {
      if(i == 0&&n != 1)
      {
        ans[i] = 1;
      }
      else
      {
        ans[i] = 0;
      }
    }
    cout << ans[i];
  }
  fin("")
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

Measured memory_bytes: 256