// created by callmepandey at 20200917 19:56.
// Rules of Optimization:
// Rule 1: Don't do it.
// Rule 2 (for experts only): Don't do it yet

#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
vector <ll> primes(1000001,1) , pr;
void prime()
{
  primes[1] = 0;
  for(ll i =2;i*i<1000001;i++)
  {
    if(primes[i])
    {
      for(ll j=i*i;j<1000001;j=j+i)
      {
        primes[j] = 0;
      }
    }
  }
  for(ll i=2;i<1000001;i++)
  {
    if(primes[i])
    pr.pb(i);
  }

}
bool check(ll n)
{
  float x = sqrt((double)n);
  ll y = x;
  if(x==y)
    return true;
  else return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   //freopen("error.txt", "w", stderr);
   freopen("output.txt", "w", stdout);
#endif

 ll T = 1 ;
 //cin>>T;

 for(ll t=0;t<T;t++)
 {
   ll n , m;
   cin>>n>>m;
   vector <pair<ll , ll>>inc;
   vector <pair<ll , ll>> dec;
   while(m--)
   {
     ll o , i , j;
     cin>>o>>i>>j;
     i-- , j--;
     if(o==1)
     {
       inc.pb({i,j});
     } else dec.pb({i,j});
   }
   ll arr[n] = {0};
   for(auto x:inc)
   {
     for(ll i=x.first+1;i<=x.second-1;i++)
     {
       arr[i] = 1;
     }
   }
   ll flag = 0;
   for(auto x:dec)
   {
     flag = 0;
     //cout<<x.first<<" "<<x.second<<endl;
     for(ll i=x.first;i<=x.second;i++)
     {
       if(arr[i]==0)
       {
         flag = 1;
         break;
       }
     }
     if(flag==0)
     {
       cout<<"NO"<<endl;
       return 0;
     }
   }
   ll ans[n] , x = 1000;
   for(ll i=0;i<n;i++)
   {
     if(arr[i]==0)
     {
       x++;
       ans[i] = x;
       if(i+1<n&&arr[i+1]==0)
       {x--;
       ans[i+1] = x;
       i++;}
     } else {
       ans[i] = x;
       x++;
     }
   }
   for(ll i=0;i<n;i++)
   {
     cout<<ans[i]<<" ";
   }
 }
  return 0;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+1]={};
    a[0]=100000;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            a[l[i]]=max(ll(1),a[l[i]]);
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=max(a[j]+1,a[j-1]+1);
            }
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(t[i]==0){
            /*
            for(ll i=1;i<=n;i++){
                cout<<a[i]<<" ";
            }
            cout<<"\n";
            */
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
            if(ans){
                continue;
            }
            for(ll j=l[i];j<=r[i];j++){
                if(a[j]==0){
                    a[j]=a[j-1]-1;
                    ans=true;
                    break;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]+1000<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll p9=1000000000;
int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=p9;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            if(a[l[i]]==0){
                a[l[i]]=p9;
                p9-=n;
            }
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=a[j-1];
            }
        }
    }
    bool ans=true;
    for(ll i=1;i<=n;i++){
        if(a[i]==0){
            a[i]=a[i-1]-1;
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]){
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=false;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+1]={};
    a[0]=100000;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            a[l[i]]=max(ll(1),a[l[i]]+1);
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=a[j-1]+1;
            }
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(t[i]==0){
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
            if(ans){
                continue;
            }
            for(ll j=l[i];j<=r[i];j++){
                if(a[j]==0){
                    a[j]=a[j-1]-1;
                    ans=true;
                    break;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]+1000<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+1]={};
    a[0]=100000;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=max(a[j]+1,a[j-1]);
            }
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(t[i]==0){
            /*
            for(ll i=1;i<=n;i++){
                cout<<a[i]<<" ";
            }
            cout<<"\n";
            */
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
            if(ans){
                continue;
            }
            for(ll j=l[i];j<=r[i];j++){
                if(a[j]==0){
                    a[j]=a[j-1]-1;
                    ans=true;
                    break;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]+1000<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define p5 100000

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll t[m],l[m],r[m];
    ll a[n+1];
    memset(a,0,sizeof(a));
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            if(a[l[i]]==0){
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=1;
                }
            }else{
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=max(a[j]+1,a[j-1]);
                }
            }
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]==1){
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=max(a[j],a[j-1]);
            }
        }
    }
    for(ll i=1;i<=n;i++){
        if(a[i]==0) a[i]=p5;
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(!ans){
            break;
        }
        if(t[i]==0){
            ans=false;
            ll mn=inf;
            ll mx=-1;
            for(ll j=l[i];j<=r[i];j++){
                mn=min(mn,a[j]);
                mx=max(a[j],mx);
                if(a[j]<mx){
                    ans=true;
                }
            }
            if(mn>=p5){
                for(ll j=l[i];j<=r[i];j++){
                    if(a[j]==mn){
                        a[j]=mn+1;
                        break;
                    }
                }
                ans=true;
            }
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll t[m],l[m],r[m];
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            dp[r[i]]+=1;
        }else{
            dp[r[i]]-=1;
        }
    }
    dp[0]=10000;
    for(ll i=1;i<=n;i++){
        dp[i]+=dp[i-1];
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(!ans){
            break;
        }
        if(t[i]==1){
            for(ll j=l[i];j<r[i];j++){
                if(dp[j]>dp[j+1]){
                    ans=false;
                    break;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(dp[j]>dp[j+1]){
                    ans=true;
                    break;
                }
            }
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<dp[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define p5 100000

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll t[m],l[m],r[m];
    ll a[n+1];
    memset(a,0,sizeof(a));
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            if(a[l[i]]==0){
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=1;
                }
            }else{
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=max(a[j]+1,a[j-1]);
                }
            }
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]==1){
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=max(a[j],a[j-1]);
            }
        }
    }
    for(ll i=1;i<=n;i++){
        if(a[i]==0) a[i]=p5;
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(!ans){
            break;
        }
        if(t[i]==0){
            ans=false;
            ll mn=pow(10,9);
            ll mx=-1;
            for(ll j=l[i];j<=r[i];j++){
                mn=min(mn,a[j]);
                mx=max(a[j],mx);
                //cout<<"Aj "<<a[j]<<"\n";
                if(a[j]<mx){
                    ans=true;
                }
            }
            if(mn>=p5){
                a[l[i]]=mn+1;
                ans=true;
            }
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define p5 100000

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll t[m],l[m],r[m];
    ll a[n+1];
    memset(a,0,sizeof(a));
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            if(a[l[i]]==0){
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=1;
                }
            }else{
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=max(a[j]+1,a[j-1]);
                }
            }
        }
    }
    for(ll i=1;i<=n;i++){
        if(a[i]==0) a[i]=p5;
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(!ans){
            break;
        }
        if(t[i]==0){
            ans=false;
            ll mn=pow(10,9);
            ll mx=-1;
            for(ll j=l[i];j<=r[i];j++){
                mn=min(mn,a[j]);
                mx=max(a[j],mx);
                //cout<<"Aj "<<a[j]<<"\n";
                if(a[j]<mx){
                    ans=true;
                }
            }
            if(mn>=p5){
                a[l[i]]=mn+1;
                ans=true;
            }
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=0;
    a[n]=0;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            a[l[i]]=max(ll(1),a[l[i]]+1);
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=a[j-1]+1;
            }
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(t[i]==0){
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
            if(ans){
                continue;
            }
            for(ll j=l[i];j<=r[i];j++){
                if(a[j]==0){
                    a[j]=min(a[j-1],a[j+1])-1;
                    ans=true;
                    break;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]+1000<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=0;
    a[n]=0;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            a[l[i]]=max(ll(1),a[l[i]]+1);
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=a[j-1]+1;
            }
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(t[i]==0){
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
            if(ans){
                continue;
            }
            for(ll j=l[i]+1;j<r[i];j++){
                if(a[j]==0){
                    a[j]=a[j-1]-1;
                    ans=true;
                    break;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]+1000<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll p9=1000000000;
int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=0;
    a[n]=0;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            if(a[l[i]]==0){
                a[l[i]]=p9;
                p9-=n;
            }
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=a[j-1];
            }
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(t[i]==0){
            for(ll j=l[i]+1;j<=r[i];j++){
                if(a[j]==0){
                    a[j]=a[j-1]-1;
                }
            }
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]){
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=false;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll p9=1000000000;
int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=p9;
    p9=p9/10;
    ll t[m],l[m],r[m];
    vector<pll>inc;
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            inc.push_back(make_pair(l[i],r[i]));
        }
    }
    sort(inc.begin(),inc.end());
    for(auto it:inc){
        if(a[it.f]==0){
            a[it.f]=p9;
            p9=p9-n-1;
        }
        for(ll j=it.f+1;j<=it.s;j++){
            a[j]=a[j-1];
        }
    }
    bool ans=true;
    for(ll i=1;i<=n;i++){
        if(a[i]==0){
            a[i]=a[i-1]-1;
        }
    }
    /*
    for(ll i=1;i<=n;i++){
        cout<<a[i]<<"\n";
    }
    */
    for(ll i=0;i<m;i++){
        if(t[i]){
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=false;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll p9=1000000000;
int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=p9;
    ll t[m],l[m],r[m];
    vector<pll>inc;
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            inc.push_back(make_pair(l[i],r[i]));
        }
    }
    sort(inc.begin(),inc.end());
    for(auto it:inc){
        if(a[it.f]==0){
            a[it.f]=p9;
            p9=p9-n-1;
        }
        for(ll j=it.f+1;j<=it.s;j++){
            a[j]=a[j-1];
        }
    }
    bool ans=true;
    for(ll i=1;i<=n;i++){
        if(a[i]==0){
            a[i]=a[i-1]-1;
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]){
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=false;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define p5 100000

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll t[m],l[m],r[m];
    ll a[n+1];
    memset(a,0,sizeof(a));
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            if(a[l[i]]==0){
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=1;
                }
            }else{
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=max(a[j]+1,a[j-1]);
                }
            }
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]==1){
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=max(a[j],a[j-1]);
            }
        }
    }
    for(ll i=1;i<=n;i++){
        if(a[i]==0) a[i]=p5;
        else a[i]+=1000;
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(!ans){
            break;
        }
        if(t[i]==0){
            ans=false;
            ll mn=inf;
            ll mx=-1;
            for(ll j=l[i];j<=r[i];j++){
                //cout<<"AJ "<<a[j]<<"\n";
                mn=min(mn,a[j]);
                mx=max(a[j],mx);
                if(a[j]<mx){
                    ans=true;
                }
            }
            if(mn>=p5){
                for(ll j=l[i];j<=r[i];j++){
                    if(a[j]==mn){
                        a[j]=mn+1;
                        break;
                    }
                }
                ans=true;
            }
            if(!ans){
                if(mx>=p5){
                    for(ll j=l[i];j<=r[i];j++){
                        if(a[j]>=p5){
                            a[j]=a[j-1]-1;
                            ans=true;
                            break;
                        }
                    }
                }
            }
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll p9=1000000000;
int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=p9;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            if(a[l[i]]==0){
                a[l[i]]=p9;
                p9-=n;
            }
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=a[j-1];
            }
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(t[i]==0){
            if(a[l[i]]==0){
                a[l[i]]=p9;
            }
            for(ll j=l[i]+1;j<=r[i];j++){
                if(a[j]==0){
                    a[j]=a[j-1]-1;
                }
            }
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]){
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=false;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll t[m],l[m],r[m];
    ll a[n+1];
    memset(a,0,sizeof(a));
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            if(a[l[i]]==0){
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=1;
                }
            }else{
                for(ll j=l[i];j<=r[i];j++){
                    a[j]=max(a[j]+1,a[j-1]);
                }
            }
        }
    }
    for(ll i=1;i<=n;i++){
        if(a[i]==0){
            a[i]=pow(10,8);
        }else{
            a[i]+=10000;
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(!ans){
            break;
        }
        if(t[i]==0){
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                    break;
                }
            }
        }
    }
    /*
    for(ll i=0;i<m;i++){
        if(!ans){
            break;
        }
        if(t[i]==1){
            for(ll j=l[i];j<r[i];j++){
                if(dp[j]>dp[j+1]){
                    ans=false;
                    break;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(dp[j]>dp[j+1]){
                    ans=true;
                    break;
                }
            }
        }
    }
    */
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=0;
    a[n]=0;
    ll t[m],l[m],r[m];
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            a[l[i]]=max(ll(1),a[l[i]]+1);
            for(ll j=l[i]+1;j<=r[i];j++){
                a[j]=a[j-1]+1;
            }
        }
    }
    bool ans=true;
    for(ll i=0;i<m;i++){
        if(t[i]==0){
            for(ll j=l[i]+1;j<=r[i];j++){
                if(a[j]==0){
                    a[j]=a[j-1]-1;
                }
            }
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]){
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=false;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]+1000<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
#define s second
#define f first
#define mod 1000000007
#define inf 1000000000000000000
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll p9=1000000000;
int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+2]={};
    a[0]=p9;
    ll t[m],l[m],r[m];
    vector<pll>inc;
    for(ll i=0;i<m;i++){
        cin>>t[i]>>l[i]>>r[i];
        if(t[i]==1){
            inc.push_back(make_pair(l[i],r[i]));
        }
    }
    sort(inc.begin(),inc.end());
    for(auto it:inc){
        if(a[it.f]==0){
            a[it.f]=p9;
            p9=p9-n-1;
        }else{
            a[it.f]=a[it.f-1];
        }
        for(ll j=it.f+1;j<=it.s;j++){
            a[j]=a[j-1];
        }
    }
    bool ans=true;
    for(ll i=1;i<=n;i++){
        if(a[i]==0){
            a[i]=a[i-1]-1;
        }
    }
    for(ll i=0;i<m;i++){
        if(t[i]){
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=false;
                }
            }
        }else{
            ans=false;
            for(ll j=l[i];j<r[i];j++){
                if(a[j]>a[j+1]){
                    ans=true;
                }
            }
        }
        if(!ans){
            break;
        }
    }
    if(ans){
        cout<<"YES\n";
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }else{
        cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isIn(int a, int b, int c, int d){
    return (a <= c) && (d <= b);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
                continue;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = n + 10;
    for(int i = 0, L = vv.size(); i + 1 < L; i++, id--){
        if(vv[i].second + 1 != vv[i + 1].first){
            vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
        }
    }

    sort(vv.begin(), vv.end());
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isIn(int a, int b, int c, int d){
    return (a <= c) && (d <= b);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

bool assignedFully(int l, int r){
    for(int i = l; i <= r; i++){
        if(ans[i] == 0)
            return false;
    }
    return true;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
                continue;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = n + 10;
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!assignedFully(l[i], r[i])){
                if(ans[l[i]] != 0){
                    int foo = ans[l[i]] - 1;
                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }
                } else if(ans[r[i]] != 0){
                    int foo = ans[r[i]] + 1;
                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }
                } else {
                    int foo = 0;
                    for(int j = l[i]; j <= r[i]; j++){
                        foo = max(foo, ans[j]);
                    }

                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }
                }
                continue;
            }
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    for(int i = 1; i <= n; i++){
        if(!ans[i]){
            ans[i] = 1;
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int t[maxN], l[maxN], r[maxN], ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isIn(int a, int b, int c, int d){
    return (a <= c) && (d <= b);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
                continue;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = n;
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = 1000;
    for(int i = 0, L = vv.size(); i + 1 < L; i++){
        if(vv[i].second + 1 != vv[i + 1].first){
            vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
        }
    }
    if(!vv.empty() && vv[0].first != 1){
        vv.push_back(make_pair(1, vv[0].first - 1));
    }

    sort(vv.begin(), vv.end());
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 1; i <= n; i++){
        if(!ans[i]){
            ans[i] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isIn(int a, int b, int c, int d){
    return (a <= c) && (d <= b);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
                continue;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = n + 10;
    for(int i = 0, L = vv.size(); i + 1 < L; i++, id--){
        if(vv[i].second + 1 != vv[i + 1].first){
            vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
        }
    }

    sort(vv.begin(), vv.end());
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        //cerr << vv[i].first << ' ' << vv[i].second << '\n';
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 1; i <= n; i++){
        if(!ans[i]){
            ans[i] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1]){
//            cerr << i << ' ' << ans[i] << ' ' << ans[i + 1] << '\n';
            return true;
        }
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];
//int T[maxN], L[maxN], R[maxN];
//
//bool checkAns(){
//    for(int i = 0; i < m; i++){
//        if(T[i] == 0){
//            if(!isNotSort(L[i], R[i])){
//                cout << "WRONG AT : 0 " << L[i] << ' ' << R[i] << '\n';
//                cerr << "TEST CASE : \n";
//                for(int i = 0; i < m; i++){
//                    cerr << T[i] << ' ' << L[i] << ' ' << R[i] << '\n';
//                }
//                return false;;
//            }
//        } else {
//            if(isNotSort(L[i], R[i])){
//                cout << "WRONG AT : 1 " << L[i] << ' ' << R[i] << '\n';
//                cerr << "TEST CASE : \n";
//                for(int i = 0; i < m; i++){
//                    cerr << T[i] << ' ' << L[i] << ' ' << R[i] << '\n';
//                }
//                return false;
//            }
//        }
//    }
//
//    return true;
//}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    srand(time(NULL));

    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> t[i] >> l[i] >> r[i];
//        T[i] = t[i];
//        L[i] = l[i];
//        R[i] = r[i];
    }

//    while(true){
//        n = 200, m = 10;
//        for(int i = 0; i < m; i++){
//            T[i] = 1;
//            L[i] = rand() * rand() % n + 1;
//            R[i] = rand() * rand() % n + 1;
//            while(L[i] == R[i]){
//                R[i] = rand() % n + 1;
//            }
//            if(L[i] > R[i]){
//                swap(L[i], R[i]);
//            }
//
//            t[i] = T[i];
//            l[i] = L[i];
//            r[i] = R[i];
//        }

        vector<pair<int, int> > v;
        for(int i = 0; i < m; i++){
            if(t[i] == 1){
                v.push_back(make_pair(l[i], r[i]));
            }
        }
        sort(v.begin(), v.end());
        for(int i = 0; i < (int)v.size(); i++){
            for(int j = 0; j < (int)v.size(); j++){
                if((!excl[i]) && (!excl[j]) && (i != j)){
                    if(isIntersect(v[i].first, v[i].second, v[j].first, v[j].second)){
                        v[i].first = min(v[i].first, v[j].first);
                        v[i].second = max(v[i].second, v[j].second);
                        excl[j] = true;
                    }
                }
            }
        }

        vector<pair<int, int> > vv;
        for(int i = 0; i < (int)v.size(); i++){
            if(!excl[i]){
                vv.push_back(v[i]);
            }
        }

        sort(vv.begin(), vv.end());
        int id = 1000;
        for(int i = 0, L = vv.size(); i + 1 < L; i++){
            if(vv[i].second + 1 < vv[i + 1].first){
                vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
            }
        }
        if(!vv.empty() && vv[0].first > 1){
            vv.push_back(make_pair(1, vv[0].first - 1));
        }

        sort(vv.begin(), vv.end());
        for(int i = 0, L = vv.size(); i < L; i++, id--){
//            cerr << "!!!!!! " << vv[i].first << ' ' << vv[i].second << '\n';
            for(int j = vv[i].first; j <= vv[i].second; j++){
                ans[j] = id;
            }
        }

        for(int i = 1; i <= n; i++){
            if(ans[i] == 0){
                ans[i] = id;
            }
        }

        for(int i = 0; i < m; i++){
            if(t[i] == 0){
                if(!isNotSort(l[i], r[i])){
                    cout << "NO\n";
                    return 0;
                }
            }
        }

        cout << "YES\n";
        for(int i = 1; i <= n; i++){
            cout << ans[i] << ' ';
        }

        cout << '\n';
//        if(!checkAns()){
//            break;
//        }
//    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isIn(int a, int b, int c, int d){
    return (a <= c) && (d <= b);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

bool assignedFully(int l, int r){
    for(int i = l; i <= r; i++){
        if(ans[i] == 0)
            return false;
    }
    return true;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
                continue;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = n + 10;
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!assignedFully(l[i], r[i])){
                if(ans[l[i]] != 0){
                    int foo = ans[l[i]] - 1;
                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }
                } else if(ans[r[i]] != 0){
                    int foo = ans[r[i]] + 1;
                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }
                } else {
                    int foo = 0;
                    for(int j = l[i]; j <= r[i]; j++){
                        foo = max(foo, ans[j]);
                    }

                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }

                    if(foo == 0){
                        int bar = r[i] - l[i] + 1;
                        for(int j = l[i]; j <= r[i]; j++, bar--){
                            ans[j] = bar;
                        }
                    }
                }
                continue;
            }
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    for(int i = 1; i <= n; i++){
        if(!ans[i]){
            ans[i] = 1;
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isIn(int a, int b, int c, int d){
    return (a <= c) && (d <= b);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

bool assignedFully(int l, int r){
    for(int i = l; i <= r; i++){
        if(ans[i] == 0)
            return false;
    }
    return true;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
                continue;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = n + 10;
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!assignedFully(l[i], r[i])){
                if(ans[l[i]] != 0){
                    int foo = ans[l[i]] - 1;
                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }
                } else if(ans[r[i]] != 0){
                    int foo = ans[r[i]] + 1;
                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }
                } else {
                    int foo = 0;
                    for(int j = l[i]; j <= r[i]; j++){
                        foo = max(foo, ans[j]);
                    }

                    for(int j = l[i]; j <= r[i]; j++){
                        if(!ans[j]){
                            ans[j] = foo;
                        }
                    }
                }
                continue;
            }
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int t[maxN], l[maxN], r[maxN], ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isIn(int a, int b, int c, int d){
    return (a <= c) && (d <= b);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
                continue;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = n;
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if((t[i] == 1) && (!excl[i])){
            for(int j = 0; j < m; j++){
                if((i != j) && (t[j] == 1) && (!excl[j])){
                    if(isIntersect(l[i], r[i], l[j], r[j])){
                        l[i] = min(l[i], l[j]);
                        r[i] = max(r[i], r[j]);
                        excl[j] = true;
                    }
                }
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if((t[i] == 1) && (!excl[i])){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = 1000;
    for(int i = 0, L = vv.size(); i + 1 < L; i++){
        if(vv[i].second + 1 < vv[i + 1].first){
            vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
        }
    }
    if(!vv.empty() && vv[0].first > 1){
        vv.push_back(make_pair(1, vv[0].first - 1));
    }

    sort(vv.begin(), vv.end());
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        cerr << vv[i].first << ' ' << vv[i].second << '\n';
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 1; i <= n; i++){
        if(ans[i] == 0){
            ans[i] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(t[i] == 0){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = n + 10;
    for(int i = 0, L = vv.size(); i + 1 < L; i++, id--){
        if(vv[i].second + 1 != vv[i + 1].first){
            vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
        }
    }
    if(!vv.empty() && vv[0].first != 1){
        vv.push_back(make_pair(1, vv[0].first - 1));
    }

    sort(vv.begin(), vv.end());
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        //cerr << vv[i].first << ' ' << vv[i].second << '\n';
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 1; i <= n; i++){
        if(!ans[i]){
            ans[i] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            continue;
        }
        for(int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            if(excl[j]){
                continue;
            }
            if(!t[j]){
                continue;
            }
            if(isIntersect(l[i], r[i], l[j], r[j])){
                l[i] = min(l[i], l[j]);
                r[i] = max(r[i], r[j]);
                excl[j] = true;
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(t[i]){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = 1000;
    for(int i = 0, L = vv.size(); i + 1 < L; i++, id--){
        if(vv[i].second + 1 != vv[i + 1].first){
            vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
        }
    }
    if(!vv.empty() && vv[0].first != 1){
        vv.push_back(make_pair(1, vv[0].first - 1));
    }

    sort(vv.begin(), vv.end());
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 1; i <= n; i++){
        if(!ans[i]){
            ans[i] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(excl[i]){
            continue;
        }
        if(!t[i]){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];
int psum[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> t[i] >> l[i] >> r[i];
        if(t[i] == 0){
            continue;
        }
        psum[l[i]]++;
        psum[r[i]]--;
    }

    for(int i = 1; i <= n; i++)
        psum[i] += psum[i - 1];

    int i = 1;
    int id = 1000;
    while(i <= n){
        int delta = 0;
        while(psum[i + delta]){
            delta++;
        }

        for(int run = 0; run <= delta; run++){
            ans[i + run] = id;
        }
        id--;

        i += delta + 1;
    }

    for(int i = 0; i < m; i++){
        if(t[i] == 0){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if((t[i] == 1) && (!excl[i])){
            for(int j = 0; j < m; j++){
                if((i != j) && (t[j] == 1) && (!excl[j])){
                    if(isIntersect(l[i], r[i], l[j], r[j])){
                        l[i] = min(l[i], l[j]);
                        r[i] = max(r[i], r[j]);
                        excl[j] = true;
                    }
                }
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if((t[i] == 1) && (!excl[i])){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = 1000;
    for(int i = 0, L = vv.size(); i + 1 < L; i++){
        if(vv[i].second + 1 < vv[i + 1].first){
            vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
        }
    }
    if(!vv.empty() && vv[0].first > 1){
        vv.push_back(make_pair(1, vv[0].first - 1));
    }

    sort(vv.begin(), vv.end());
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 1; i <= n; i++){
        if(ans[i] == 0){
            ans[i] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(t[i] == 0){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1])
            return true;
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> t[i] >> l[i] >> r[i];

    for(int i = 0; i < m; i++){
        if((t[i] == 1) && (!excl[i])){
            for(int j = 0; j < m; j++){
                if((i != j) && (t[j] == 1) && (!excl[j])){
                    if(isIntersect(l[i], r[i], l[j], r[j])){
                        l[i] = min(l[i], l[j]);
                        r[i] = max(r[i], r[j]);
                        excl[j] = true;
                    }
                }
            }
        }
    }

    vector<pair<int, int> > vv;
    for(int i = 0; i < m; i++){
        if((t[i] == 1) && (!excl[i])){
            vv.push_back(make_pair(l[i], r[i]));
        }
    }

    sort(vv.begin(), vv.end());
    int id = 1000;
    for(int i = 0, L = vv.size(); i + 1 < L; i++){
        if(vv[i].second + 1 != vv[i + 1].first){
            vv.push_back(make_pair(vv[i].second + 1, vv[i + 1].first - 1));
        }
    }
    if(!vv.empty() && vv[0].first != 1){
        vv.push_back(make_pair(1, vv[0].first - 1));
    }

    sort(vv.begin(), vv.end());
    for(int i = 0, L = vv.size(); i < L; i++, id--){
        for(int j = vv[i].first; j <= vv[i].second; j++){
            ans[j] = id;
        }
    }

    for(int i = 1; i <= n; i++){
        if(ans[i] == 0){
            ans[i] = id;
        }
    }

    for(int i = 0; i < m; i++){
        if(t[i] == 0){
            if(!isNotSort(l[i], r[i])){
                cout << "NO\n";
                return 0;
            }
        }
    }

    cout << "YES\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1000 + 9;

int n, m;
int ans[maxN];
bool excl[maxN];

bool isIntersect(int a, int b, int c, int d){
    int mn = max(a, c);
    int mx = min(b, d);

    return (mn <= mx);
}

bool isNotSort(int l, int r){
    for(int i = l; i + 1 <= r; i++){
        if(ans[i] > ans[i + 1]){
//            cerr << i << ' ' << ans[i] << ' ' << ans[i + 1] << '\n';
            return true;
        }
    }
    return false;
}

int t[maxN], l[maxN], r[maxN];
//int T[maxN], L[maxN], R[maxN];
//
//bool checkAns(){
//    for(int i = 0; i < m; i++){
//        if(T[i] == 0){
//            if(!isNotSort(L[i], R[i])){
//                cout << "WRONG AT : 0 " << L[i] << ' ' << R[i] << '\n';
//                cerr << "TEST CASE : \n";
//                for(int i = 0; i < m; i++){
//                    cerr << T[i] << ' ' << L[i] << ' ' << R[i] << '\n';
//                }
//                return false;;
//            }
//        } else {
//            if(isNotSort(L[i], R[i])){
//                cout << "WRONG AT : 1 " << L[i] << ' ' << R[i] << '\n';
//                cerr << "TEST CASE : \n";
//                for(int i = 0; i < m; i++){
//                    cerr << T[i] << ' ' << L[i] << ' ' << R[i] << '\n';
//                }
//                return false;
//            }
//        }
//    }
//
//    return true;
//}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    srand(time(NULL));

    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> t[i] >> l[i] >> r[i];
//        T[i] = t[i];
//        L[i] = l[i];
//        R[i] = r[i];
    }

//    while(true){
//        n = 200, m = 10;
//        for(int i = 0; i < m; i++){
//            T[i] = 1;
//            L[i] = rand() * rand() % n + 1;
//            R[i] = rand() * rand() % n + 1;
//            while(L[i] == R[i]){
//                R[i] = rand() % n + 1;
//            }
//            if(L[i] > R[i]){
//                swap(L[i], R[i]);
//            }
//
//            t[i] = T[i];
//            l[i] = L[i];
//            r[i] = R[i];
//        }

        vector<pair<int, int> > v;
        for(int i = 0; i < m; i++){
            if(t[i] == 1){
                v.push_back(make_pair(l[i], r[i]));
            }
        }
        sort(v.begin(), v.end());
        for(int i = 0; i < (int)v.size(); i++){
            for(int j = 0; j < (int)v.size(); j++){
                if((!excl[i]) && (!excl[j]) && (i != j)){
                    if(isIntersect(v[i].first, v[i].second, v[j].first, v[j].second)){
                        v[i].first = min(v[i].first, v[j].first);
                        v[i].second = max(v[i].second, v[j].second);
                        excl[j] = true;
                    }
                }
            }
        }

        vector<pair<int, int> > vv;
        for(int i = 0; i < (int)v.size(); i++){
            if(!excl[i]){
                vv.push_back(v[i]);
            }
        }

        sort(vv.begin(), vv.end());
        int id = 1000;
        for(int i = 0, L = vv.size(); i + 1 < L; i++){
            if(vv[i].second + 1 < vv[i + 1].first){
                for(int run = vv[i].second + 1; run < vv[i + 1].first; run++){
                    vv.push_back(make_pair(run, run));
                }
            }
        }
        if(!vv.empty() && vv[0].first > 1){
            for(int run = 1; run < vv[0].first; run++){
                vv.push_back(make_pair(run, run));
            }
        }

        sort(vv.begin(), vv.end());
        for(int i = 0, L = vv.size(); i < L; i++, id--){
//            cerr << "!!!!!! " << vv[i].first << ' ' << vv[i].second << '\n';
            for(int j = vv[i].first; j <= vv[i].second; j++){
                ans[j] = id;
            }
        }

        for(int i = 1; i <= n; i++){
            if(ans[i] == 0){
                ans[i] = id;
                id--;
            }
        }

        for(int i = 0; i < m; i++){
            if(t[i] == 0){
                if(!isNotSort(l[i], r[i])){
                    cout << "NO\n";
                    return 0;
                }
            }
        }

        cout << "YES\n";
        for(int i = 1; i <= n; i++){
            cout << ans[i] << ' ';
        }

        cout << '\n';
//        if(!checkAns()){
//            break;
//        }
//    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l]==0)a[q[i].l]=2;
        int fg=0;
        for(int j=q[i].l+1;j<=q[i].r;j++)
        {
            if(a[j]==0)
            {
                if(fg==0&&q[i].t==0)
                {
                    a[j]=a[j-1]-1;fg=1;
                }
                else a[j]=a[j-1]+1;
            }
            else
            {
                if((a[j]-a[j-1]>=0&&q[i].t!=1)||(a[j]-a[j-1]<0&&q[i].t==1)){flag=1;break;}
            }
        }
        if(flag||(q[i].t==0&&fg==0)){flag=1;break;}
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l]==0)a[q[i].l]=2;
        int fg=0;
        for(int j=q[i].l+1;j<=q[i].r;j++)
        {
            if(a[j]==0)
            {
                if(fg==0&&q[i].t==0)
                {
                    a[j]=a[j-1]-1;fg=1;
                }
                else a[j]=a[j-1]+1;
            }
            else
            {
                if((a[j]-a[j-1]==1&&q[i].t!=1)||(a[j]-a[j-1]!=1&&q[i].t==1)){flag=1;break;}
            }
        }
        if(flag||(q[i].t==0&&fg==0)){flag=1;break;}
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l]==0)a[q[i].l]=2;
        if(a[q[i].l+1]!=0&&(a[q[i].l+1]-a[q[i].l]==1&&q[i].t!=1)||(a[q[i].l+1]-a[q[i].l]!=1&&q[i].t==1)){flag=1;break;}
        if(a[q[i].l+1]==0){if(q[i].t==0)a[q[i].l+1]=a[q[i].l]-1;
        else a[q[i].l+1]=a[q[i].l]+1;}
        for(int j=q[i].l+2;j<=q[i].r;j++)
        {
            if(a[q[i].l+1]==0)a[j]=a[j-1]+1;
        }
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    a[1]=10000;
    int flag=0;
    for(int i=0;i<m;i++)
    {
        for(int j=q[i].l+1;j<=q[i].r;j++)
        {
            if(a[j]==0)
            {
                //cout<<j<<endl;
                if(q[i].t==1)a[j]=a[j-1]+1;
                else a[j]=a[j-1]-1;
            }
            else
            {
                if((a[j]-a[j-1]==1&&q[i].t!=1)||(a[j]-a[j-1]!=1&&q[i].t==1)){flag=1;break;}
            }
        }
        if(flag)break;
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        for(int i=1;i<=n;i++)
        {
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    int flag=0;
    a[1]=1007;
    for(int i=0;i<m;i++)
    {
        if(i==0)
        {
            for(int j=2;j<=q[i].l;j++)
            {
                a[j]=a[j-1];
            }
        }
        else if(q[i].l>q[i-1].r)
        {
            for(int j=q[i-1].r+1;j<=q[i].l;j++)
            {
                a[j]=a[j-1];
            }
        }
        int fg=0;
        for(int j=q[i].l+1;j<=q[i].r;j++)
        {
            if(a[j]==0)
            {
                if(fg==0&&q[i].t==0)
                {
                    a[j]=a[j-1]-1;fg=1;
                }
                else a[j]=a[j-1];
            }
            else
            {
                if(a[j]!=a[j-1]&&q[i].t==1){flag=1;break;}
            }
        }
        if(flag||(q[i].t==0&&fg==0)){flag=1;break;}
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    a[1]=1;
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l+1]!=0)
        {
            if((a[q[i].l+1]-a[q[i].l]==1&&q[i].t!=1)||(a[q[i].l+1]-a[q[i].l]!=1&&q[i].t==1)){flag=1;break;}
        }
        if(q[i].t==0)a[q[i].l+1]=a[q[i].l]-1;
        else a[q[i].l+1]=a[q[i].l]+1;
        for(int j=q[i].l+2;j<=q[i].r;j++)
        {
            if(a[j]==0)
            {
               a[j]=a[j-1]+1;
            }
            else
            {
                if((a[j]-a[j-1]==1&&q[i].t!=1)||(a[j]-a[j-1]!=1&&q[i].t==1)){flag=1;break;}
            }
        }
        if(flag)break;
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l]==0)a[q[i].l]=2;
        if(a[q[i].l+1]!=0&&((a[q[i].l+1]-a[q[i].l]==1&&q[i].t!=1)||(a[q[i].l+1]-a[q[i].l]!=1&&q[i].t==1))){flag=1;break;}
        if(a[q[i].l+1]==0){if(q[i].t==0)a[q[i].l+1]=a[q[i].l]-1;
        else a[q[i].l+1]=a[q[i].l]+1;}
        for(int j=q[i].l+2;j<=q[i].r;j++)
        {
            if(a[j]==0)a[j]=a[j-1]+1;
        }
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=1e5+7;
const int inf=1e9+7;
int n,m;
string s[1005];
int a[1005][1005],b[1005][1005];
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    int ans=0;
    for(int i=0;i<n;i++)
    {
        a[i][0]=1;
        for(int j=1;j<m;j++)
        {
            if(s[i][j]==s[i][j-1])a[i][j]=a[i][j-1]+1;
            else a[i][j]=1;
        }
    }
    for(int i=0;i<m;i++)
    {
        b[0][i]=1;
        for(int j=1;j<n;j++)
        {
            if(s[j][i]==s[j-1][i])b[j][i]=b[j-1][i]+1;
            else b[j][i]=1;
        }
    }
//    for(int i=0;i<n;i++)
//    {
//        for(int j=0;j<m;j++)
//            cout<<b[i][j]<<" ";
//        cout<<endl;
//    }
    for(int i=2;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            int c1=b[i][j];
            if(3*c1>i+1)continue;
            int c2=b[i-c1][j];
            if(c1!=c2)continue;
            int c3=b[i-c1-c2][j];
            if(c3<c2)continue;
            int sum=m+7;
            for(int k=i-c1-c2-c2+1;k<=i;k++)
            {
                sum=min(sum,a[k][j]);
            }
            //cout<<i<<" "<<j<<" "<<sum<<endl;
            ans+=sum;
        }
    }
    cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    a[1]=2;
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l]==0)q[i].l=2;
        if(a[q[i].l+1]!=0)
        {
            if((a[q[i].l+1]-a[q[i].l]==1&&q[i].t!=1)||(a[q[i].l+1]-a[q[i].l]!=1&&q[i].t==1)){flag=1;break;}
        }
        if(q[i].t==0)a[q[i].l+1]=a[q[i].l]-1;
        else a[q[i].l+1]=a[q[i].l]+1;
        for(int j=q[i].l+2;j<=q[i].r;j++)
        {
            a[j]=a[j-1]+1;
        }
        if(flag)break;
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    a[1]=1;
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l+1]!=0)
        {
            if((a[q[i].l+1]-a[q[i].l]==1&&q[i].t!=1)||(a[q[i].l+1]-a[q[i].l]!=1&&q[i].t==1)){flag=1;break;}
        }
        if(q[i].t==0)a[q[i].l+1]=a[q[i].l]-1;
        else a[q[i].l+1]=a[q[i].l]+1;
        for(int j=q[i].l+2;j<=q[i].r;j++)
        {
            if(a[j]==0)
            {
               a[j]=a[j-1]+1;
            }
            else
            {
                if((a[j]-a[j-1]==1&&q[i].t!=1)||(a[j]-a[j-1]!=1&&q[i].t==1)){flag=1;break;}
            }
        }
        if(flag)break;
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    int flag=0;
    a[1]=1007;
    for(int i=0;i<m;i++)
    {
        if(i==0)
        {
            for(int j=2;j<=q[i].l;j++)
            {
                a[j]=a[j-1];
            }
        }
        else if(q[i].l>q[i-1].r)
        {
            for(int j=q[i-1].r+1;j<=q[i].l;j++)
            {
                a[j]=a[j-1];
            }
        }
        int fg=0;
        if(i!=0&&q[i].t==0&&q[i-1].t==1&&q[i].r<=q[i-1].r){flag=1;break;}
        if(i!=0&&q[i].t==0&&q[i-1].t==0&&q[i].l<q[i-1].r){a[q[i].l+1]=0;}
        for(int j=q[i].l+1;j<=q[i].r;j++)
        {
            if(a[j]==0)
            {
                if(fg==0&&q[i].t==0)
                {
                    a[j]=a[j-1]-1;fg=1;
                }
                else a[j]=a[j-1];
            }
            else
            {
                if(a[j]!=a[j-1]&&q[i].t==1){flag=1;break;}
                a[j]=a[j-1];
            }
        }
        if(flag){break;}
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l]==0)a[q[i].l]=2;
        if(i!=0&&q[i].l<q[i-1].r&&q[i].t!=q[i-1].t){flag=1;break;}
        if(q[i].t==0)a[q[i].l+1]=a[q[i].l]-1;
        else a[q[i].l+1]=a[q[i].l]+1;
        for(int j=q[i].l+2;j<=q[i].r;j++)
        {
            a[j]=a[j-1]+1;
        }
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int maxn=2e5+7;
const int inf=1e9+7;
int n,m,a[1005];
struct node
{
    int t,r,l;
}q[1005];
bool cmp(node x,node y)
{
    if(x.l==y.l)return x.r<y.r;
    else return x.l<y.l;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>q[i].t>>q[i].l>>q[i].r;
    }
    sort(q,q+m,cmp);
    a[1]=1;
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(a[q[i].l+1]!=0)
        {
            if((a[q[i].l+1]-a[q[i].l]==1&&q[i].t!=1)||(a[q[i].l+1]-a[q[i].l]!=1&&q[i].t==1)){flag=1;break;}
        }
        if(q[i].t==0)a[q[i].l+1]=a[q[i].l]-1;
        else a[q[i].l+1]=a[q[i].l]+1;
        for(int j=q[i].l+2;j<=q[i].r;j++)
        {
            a[j]=a[j-1]+1;
        }
        if(flag)break;
    }
    if(flag)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)a[i]=1;
            if(i==n)cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
vector <int> ve[205];
int n,m;
bool used[105];
void dfs(int u){
	used[u]=true;
	for (int i=0;i<ve[u].size();i++){
		if (!used[ve[u][i]]) dfs(ve[u][i]);
	}
}
int main(){
	cin>>n>>m;
	bool hav=false;
	for (int i=0;i<n;i++){
		int a,b;
		cin>>a;
		if (a) hav=true;
		for (int j=0;j<a;j++){
			cin>>b;
			ve[i].push_back(b+100);
			ve[b+100].push_back(i);
		}
	}
	int ans=0;
	for (int i=0;i<n;i++){
		if (!used[i]){
			dfs(i);
			ans++;
		}
	}
	if (hav) cout<<ans-1; else cout<<n;
	return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<set>
#include<map>
#include<queue>
#include<functional>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<cstdio>
#include<ctime>
#include<algorithm>
#define mp make_pair
#define pb push_back
#define rep(i,j,k) for(int (i)=(j);(i)<=k;(i)++)
using namespace std;
bool used[103];
int n,m,a,b,k,qq,ans;
vector<int>v[1004];
void dfs(int i){
	used[i]=true;
	for(int j=0;j<v[i].size();j++){
		if(!used[v[i][j]]){dfs(v[i][j]);}
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>k;if(k==0)qq++;
		for(int j=1;j<=k;j++){
			cin>>a;
			v[a+100].push_back(i);
			v[i].push_back(a+100);
		}
	}
	if(qq==n){cout<<n;return 0;}
	b=n;
	for(int i=1;i<=b;i++){
		if(!used[i]){dfs(i);ans++;}
		//cout<<i<<' '<<b<<endl;system("pause");
		if(i>b)break;
	}
	cout<<ans-1;
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int v[205],a[205],fa[205],n,m,k,ans;
int get(int x){
	if (x==fa[x]) return x;
	return fa[x]=get(fa[x]);
}
int main(){
	cin>>n>>m;
	for (int i=1;i<=m;i++) fa[i]=i;
	for (int i=1;i<=n;i++){
		cin>>k;
		if (!k) ans++;
		for (int j=1;j<=k;j++) cin>>a[j],v[a[j]]=1;
		for (int j=1;j<k;j++) fa[get(a[j])]=get(a[j+1]);
	}
	if (ans==n){
		cout<<n;
		return 0;
	}else{
		for (int i=1;i<=m;i++){
			if (v[i] && get(i)==i) ans++;
		}
		cout<<ans-1;
		return 0;
	}
}


#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
vector <int> ve[205];
int n,m;
bool used[105];
void dfs(int u){
	used[u]=true;
	for (int i=0;i<ve[u].size();i++){
		if (!used[ve[u][i]] || u>=100) dfs(ve[u][i]);
	}
}
int main(){
	cin>>n>>m;
	bool hav=false;
	for (int i=0;i<n;i++){
		int a,b;
		cin>>a;
		if (a) hav=true;
		for (int j=0;j<a;j++){
			cin>>b;
			ve[i].push_back(b+100);
			ve[b+100].push_back(i);
		}
	}
	int ans=0;
	for (int i=0;i<n;i++){
		if (!used[i]){
			dfs(i);
			ans++;
		}
	}
	if (hav) cout<<ans-1; else cout<<n;
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int v[205],a[205],fa[205],n,m,k,ans;
int get(int x){
	if (x==fa[x]) return x;
	return fa[x]=get(fa[x]);
}
int main(){
	cin>>n>>m;
	for (int i=1;i<=m;i++) fa[i]=i;
	for (int i=1;i<=n;i++){
		cin>>k;
		if (!k) ans++;
		for (int j=1;j<=k;j++) cin>>a[j],v[a[j]]=1;
		for (int j=1;j<k;j++) fa[get(a[j])]=get(a[j+1]);
	}
	if (ans==n){
		cout<<n;
		return 0;
	}else{
		ans=0;
		for (int i=1;i<=n;i++){
			if (v[i] && get(i)==i) ans++;
		}
		cout<<ans;
		return 0;
	}
}


#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
vector <int> ve[205];
int n,m;
bool used[205];
void dfs(int u){
	used[u]=true;
	for (int i=0;i<ve[u].size();i++){
		if (!used[ve[u][i]] || ve[u][i]>=100) dfs(ve[u][i]);
	}
}
int main(){
	cin>>n>>m;
	bool hav=false;
	for (int i=0;i<n;i++){
		int a,b;
		cin>>a;
		if (a) hav=true;
		for (int j=0;j<a;j++){
			cin>>b;
			ve[i].push_back(b+100);
			ve[b+100].push_back(i);
		}
	}
	int ans=0;
	for (int i=0;i<n;i++){
		if (!used[i]){
			dfs(i);
			ans++;
		}
	}
	if (hav) cout<<ans-1; else cout<<n;
	return 0;
}