Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| ≤ 1.Iahub thinks that point x belongs to segment [l, r], if inequality l ≤ x ≤ r holds.Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.

The first line of input contains two integers: n (1 ≤ n ≤ 100) and m (1 ≤ m ≤ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 ≤ xi ≤ 100) — the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 ≤ li ≤ ri ≤ 100) — the borders of the i-th segment. It's guaranteed that all the points are distinct.

If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue). If there are multiple good drawings you can output any of them.

uses math;
const Nmax=1000;
var k,x,a: array[0..Nmax] of longint;

     n,m,i,j,l,r,t: longint;

begin
//  assign(input,'input.txt'); reset(input);
//  assign(output,'output.txt'); rewrite(output);

    read(n,m);

    for i:=1 to n do begin read(x[i]); inc(k[x[i]]); end;
    for i:=1 to m do read(l,r);

    t:=0;
    for i:=0 to 100 do
      if k[i]>0
        then for j:=1 to n do
               if i=x[j] then begin inc(t); a[j]:=t mod 2 end;

    for i:=1 to n do  write(a[i],' ');

end.

  program Pr1;

{$APPTYPE CONSOLE}

label 1,2,3,4;
const modul=100000007;  besk=100000000;  besk1=1000000000000;  eps=1e-10;
type double=extended;
mas=array[-10..2000000] of int64; mass=^mas;
var bb,n1,n2,kol,jj,n,k,i,j: longint;
fact,a,d,ot2,numi,numj,newobr,obr,pred,next,b,c:array[-1000..2000000] of int64;
zan,pr: array[0..5000000] of boolean;
x,y:array[-10..200000] of double;
sss1,sss2,sss:string;
per:mas;
flag:boolean;
p,r,period,l,mmod,pos,iot,jot,kk,pmin,imin,pmax,imax,i1,i2,j1,j2,qq,pp,iii,p1,p2,kolelem,tt,ot,s,t,al,m:int64;
pole1:array[-10..600,-10..600] of char;
otch:array[0..1000000] of char;
beta,otold,otnew,x2,x0,x1,aa,cc:double;
dd5,dd6,dd2,dd3,dd4,dd1,pole,cena:array[-10..1100,-10..1100] of int64;
marked:array[-10..60000] of boolean;
napx,napy: array[-10..600] of  longint;
function max(a,b:int64):int64; begin max:=a;if b>a then max:=b; end;
function min(a,b:int64):int64; begin min:=a;if b<a then min:=b; end;

function step(a,k:int64):int64; var p,t:int64;
begin
 if k=0 then step:=1 else
 begin;
    if odd(k) then step:=step(a,k-1)*a mod modul else
      begin
        t:=k div 2; p:=step(a,t); step:=p*p mod modul;
      end;

 end;
end;

begin
 {reset(input,'F:\Projects\input.txt');close(input);
 rewrite(output,'F:\Projects\output.txt');close(output);
  }

  read(n,k);
 for i:=1 to n do read(a[i]);
 for i:=1 to n do b[i]:=i;
 for i:=1 to n do for j:=1 to n-1 do if a[j]>a[j+1] then
   begin t:=a[j]; a[j]:=a[j+1];a[j+1]:=t;   t:=b[j]; b[j]:=b[j+1];b[j+1]:=t;        end;

 for i:=1 to n do c[b[i]]:=i mod 2;
 for i:=1 to n do write(c[i],' ');

   1: close (output);
end.

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
  const MD=round(1e9)+7;
  const in_file='input.txt';
  const out_file='output.txt';
  var
  i,j,n,m,k,l,r:longint;
  a,ind,ans:array[1..100] of integer;
  procedure QSort(l,r:integer);
  var
  buf,key:int64;
  i,j:integer;
  begin
  if l>=r  then exit;
  key:=a[l+random(r-l)];
  i:=l;
  j:=r;
  repeat
  while a[i]<key do inc(i);
  while a[j]>key do dec(j);
  if (i<=j) then
  begin
  buf:=a[i];
  a[i]:=a[j];
  a[j]:=buf;
  buf:=ind[i];
  ind[i]:=ind[j];
  ind[j]:=buf;
   i:=i+1;
   j:=j-1;
  end;
  until j<i;
  QSort(l,j);
  Qsort(i,r);
  end;

begin
//assign(input,in_file); reset(input);
//assign(output,out_file); rewrite(output);
    readln(n,m);
    fillchar(a,sizeof(a),0);
    for i:=1 to n do begin read(a[i]); ind[i]:=i; end;
     QSort(1,n);
     readln;
     for i:=1 to m do readln(l,r);
     fillchar(ans,sizeof(ans),0);
     for i:=1 to n do ans[ind[i]]:=i mod 2;

     for i:=1 to n do write(ans[i],' ');
     readln;
     readln;

//close(output);
//close(input);
end.

var n,m,i,j,k:longint;
    a,b,c,d,f:array[1..100]of longint;
begin
  read(n,m);
  for i:=1 to n do begin read(a[i]); d[i]:=i end;
  for i:=1 to m do read(b[i],c[i]);
  for i:=1 to n do
    for j:=1 to n-1 do
      if a[j]>a[j+1]then
      begin
        k:=a[j]; a[j]:=a[j+1]; a[j+1]:=k;
        k:=d[j]; d[j]:=d[j+1]; d[j+1]:=k;
      end;
  for i:=1 to n do f[d[i]]:=i mod 2;
  for i:=1 to n do write(f[i],' ')
end.

var q,j,n,m,b,i:longint;
c,a,ni:array[0..1000] of longint;
begin
 read(n,m);
 for i:=1 to n do
  begin
  read(a[i]);
   ni[i]:=i;
  end;
  for i:=1 to m do
   read(b,b);
  for i:=1 to n-1 do
   for j:=i+1 to n do
    if a[i]<a[j] then
     begin
      b:=a[i];
      a[i]:=a[j];
      a[j]:=b;
      b:=ni[i];
      ni[i]:=ni[j];
      ni[j]:=b;
     end;
 for i:=1 to n do
  if i mod 2=0 then c[ni[i]]:=1
  else c[ni[i]]:=0;
 for i:=1 to n do
  write(c[i],' ');
end.

var a,b,x:array[0..100] of integer;
    i,n,m,k:integer;
begin
   readln(n,m);
   for i:=1 to n do
      begin
        read(x[i]);
        a[x[i]]:=i;
      end;
   for i:=0 to 100 do
      if a[i]<>0 then
          begin
             inc(k);
             b[a[i]]:=k mod 2;
          end;
   for i:=1 to n do write(b[i],' ');
   readln;
end.

var a,b:array[0..100] of integer;
    x:array[1..100] of integer;
    n,i,m,k:integer;
begin

    readln(n,m);
    for i:=1 to n do
       begin
          read(x[i]);
          a[x[i]]:=i;
       end;
    k:=0;
    for i:=0 to 100 do
       if a[i]<>0 then
          begin
             inc(k);
             b[a[i]]:=k mod 2;
          end;
    for i:=1 to n do write(b[i],' ');
end.

const   fi='';
        fo='';
var     f,g:text;
        kq,a,b:array[0..105] of integer;
        n,m,i:integer;
        procedure qsort(dau,cuoi:integer);
        var     x,i,j,t:integer;
                begin
                        if dau>=cuoi then exit;
                        i:=dau;
                        j:=cuoi;
                        x:=b[a[(dau+cuoi) div 2]];
                        repeat
                                while b[a[i]]<x do i:=i+1;
                                while b[a[j]]>x do j:=j-1;
                                if i<=j then
                                begin
                                        t:=a[i];
                                        a[i]:=a[j];
                                        a[j]:=t;
                                        i:=i+1;
                                        j:=j-1;
                                end;
                        until i>j;
                        qsort(dau,j);
                        qsort(i,cuoi);
                end;
begin
        assign(f,fi);
        reset(f);
        assign(g,fo);
        rewrite(g);
        readln(f,n,m);
        for i:=1 to n do
                read(F,b[i]);
        close(f);

        for i:=1 to n do
                a[i]:=i;
        qsort(1,n);
        for i:=1 to n do
                kq[a[i]]:=i mod 2;
        for i:=1 to n do
                write(G,kq[i],' ');
        close(G);
end.

{$MODE OBJFPC}
program PointsAndSegments;
const
    fin='';
    fou='';
    maxN=100;
    maxM=100;

var
    a:array[1..maxN] of longint;
    p:array[1..maxN] of integer;
    c:array[1..maxN] of integer;
    n,m:integer;
    fi,fo:text;

procedure   swap(var x,y:integer);
var
    tmp:integer;
begin
    tmp:=x;
    x:=y;
    y:=tmp;
end;

procedure   Sort(l,r:integer);
var
    i,j:integer;
    v:longint;
begin
    i:=l;
    j:=r;
    v:=a[p[(l+r) div 2]];
    repeat
        while (a[p[i]]<v) do inc(i);
        while (a[p[j]]>v) do dec(j);
        if (i<=j) then
        begin
            swap(p[i],p[j]);
            inc(i);
            dec(j);
        end;
    until   (i>j);
    if (l<j) then Sort(l,j);
    if (i<r) then Sort(i,r);
end;

procedure   main();
var
    i:integer;
begin
    Assign(fi,fin);Reset(fi);
    Read(fi,n,m);
    for i:=1 to n do
        Read(fi,a[i]);
    Close(fi);
    for i:=1 to n do
        p[i]:=i;
    Sort(1,n);
    c[p[1]]:=0;
    for i:=2 to n do
        c[p[i]]:=1-c[p[i-1]];
    Assign(fo,fou);Rewrite(fo);
    for i:=1 to n do
        Write(fo,c[i],' ');
    Close(fo);
end;

begin
    main();
end.

{$MODE OBJFPC}
type
  poi=record
    co:integer;
    dex:integer; x:integer;
  end;
const
  fo='';
  fi='';
var
  n,m:integer;
  a:array[1..100] of poi;
  b,c:array[0..101] of integer;
procedure input;
var f:textfile; i,j:integer;
begin
  assign(f,fo);
  reset(f);
  readln(f,n,m);
  for i:=1 to n do begin read(f,a[i].x); a[i].dex:=i end;
  readln(f);
  for j:=1 to m do readln(f,b[j],c[j]);
  close(f);
end;
procedure QS(l,h:integer);
var i,j:integer; pivot:poi;
begin
  if l>=h then exit;
  i:=random(h-l+1)+l; j:=h; pivot:=a[i];
  a[i]:=a[l]; i:=l;
  repeat
    while (i<j) and (a[j].x>pivot.x) do dec(j);
      if i<J then begin a[i]:=a[j]; inc(i) end else break;
    while (i<j) and (a[i].x<pivot.x) do inc(i);
      if i<j then begin a[j]:=a[i]; dec(j) end else break;
  until i=j;
  a[i]:=pivot;
  QS(l,i-1);
  QS(i+1,h);
end;
procedure QS2(l,h:integer);
var i,j:integer; pivot:poi;
begin
  if l>=h then exit;
  i:=random(h-l+1)+l; j:=h; pivot:=a[i];
  a[i]:=a[l]; i:=l;
  repeat
    while (i<j) and (a[j].dex>pivot.dex) do dec(j);
      if i<J then begin a[i]:=a[j]; inc(i) end else break;
    while (i<j) and (a[i].dex<pivot.dex) do inc(i);
      if i<j then begin a[j]:=a[i]; dec(j) end else break;
  until i=j;
  a[i]:=pivot;
  QS2(l,i-1);
  QS2(i+1,h);
end;
procedure solve;
var i:integer;
begin
  for i:=1 to n do a[i].co:=i mod 2;
end;
procedure output;
var f:textfile; i:integer;
begin
  assign(f,fi);
  rewrite(f);
  for i:=1 to n do write(f,a[i].co,' ');
  close(f);
end;
begin
  input;
  QS(1,n);
  solve;
  QS2(1,n);
  output;
end.

program points;
var a,b,mau:array[0..1000] of longint;
    m,n,i,j,x,y,z:longint;
begin
     read(n);
     read(m);
     for i:=1 to n do
     begin
          read(a[i]);
     end;
     for i:=1 to n do
     begin
          b[i]:=a[i];
     end;
     for i:=1 to m do
     begin
          read(x);
          read(y);
     end;
     for i:=1 to n-1 do
     begin
          for j:=i+1 to n do
          begin
               if b[i] > b[j] then
               begin
                    z:=b[i];
                    b[i]:=b[j];
                    b[j]:=z;
               end;
          end;
     end;
     for i:=1 to n do
     begin
          z:=b[i];
          if i mod 2 = 0 then
          begin
               mau[z]:=0;
          end;
          if (i mod 2 <> 0) then
          begin
               mau[z]:=1;
          end;
     end;
     for i:=1 to n do
     begin
          z:=a[i];
          write(mau[z],' ');
     end;

end.

Var a,b,c,kol,ans:array[1..1000000] of longint;
    i,j,k,m,l,o,p,n:longint;

    procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                y:=kol[i];
                kol[i]:=kol[j];
                kol[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

    procedure ssort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=kol[(l+r) div 2];
         repeat
           while kol[i]<x do
            inc(i);
           while x<kol[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                 y:=kol[i];
                kol[i]:=kol[j];
                kol[j]:=y;
                 y:=ans[i];
                ans[i]:=ans[j];
                ans[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           ssort(l,j);
         if i<r then
           ssort(i,r);
      end;

 Begin
  read(n,m);
  for i:=1 to n do begin read(a[i]); kol[i]:=i;; end;
  for i:=1 to m do read(b[i],c[i]);
  sort(1,n);
  for i:=1 to n do begin ans[i]:=i mod 2; end;
  ssort(1,n);
  for i:=1 to n do write(ans[i],' ')
 end.

program abc;
var j,n,m,b,i:longint;
c,a,ni:array[0..1000] of longint;
begin
 read(n,m);
 for i:=1 to n do
  begin
  read(a[i]);
   ni[i]:=i;
  end;
  for i:=1 to m do
   read(b,b);
  for i:=1 to n-1 do
   for j:=i+1 to n do
    if a[i]<a[j] then
     begin
      b:=a[i];
      a[i]:=a[j];
      a[j]:=b;
      b:=ni[i];
      ni[i]:=ni[j];
      ni[j]:=b;
     end;
 for i:=1 to n do
  if i mod 2=0 then c[ni[i]]:=1
  else c[ni[i]]:=0;
 for i:=1 to n do
  write(c[i],' ');
end.

var n,m,i,a,b:integer;
    x,pos,ans:array[1..100]of integer;
procedure sort(l,r:integer);
var p,q,z,temp:integer;
begin
    p:=l;q:=r;
    z:=x[p+random(q-p)];
    while p<=q do begin
        while z>x[p] do inc(p);
        while x[q]>z do dec(q);
        if p<=q then begin
            temp:=x[p];x[p]:=x[q];x[q]:=temp;
            temp:=pos[p];pos[p]:=pos[q];pos[q]:=temp;
            inc(p);
            dec(q);
        end;
    end;
    if l<q then sort(l,q);
    if p<r then sort(p,r);
end;
begin
    randomize;
    readln(n,m);
    for i:=1 to n do begin
        read(x[i]);
        pos[i]:=i;
    end;
    readln;
    sort(1,n);
    for i:=1 to n do
        if odd(i) then x[i]:=1
        else x[i]:=0;
    for i:=1 to n do
        ans[pos[i]]:=x[i];
    for i:=1 to m do
        readln(a,b);
    for i:=1 to n do
        write(ans[i],' ');
    readln;
end.

var
   n,m,i,j,g : longint;
   x : array [1..2,1..100] of longint;
   a : array [1..3,1..100] of longint;
procedure qSort1(l,r : longint);
 var k,i,j,y:longint;
 begin
    i:=l;
    j:=r;
    k:=a[1,(l+r) div 2];
    repeat
       while a[1,i]<k do inc(i);
       while a[1,j]>k do dec(j);
       if i<=j then
          begin
             y:=a[1,i]; a[1,i]:=a[1,j]; a[1,j]:=y;
             y:=a[2,i]; a[2,i]:=a[2,j]; a[2,j]:=y;
             inc(i); dec(j);
          end;
    until i>j;
    if l<j then qsort1(l,j);
    if i<r then qsort1(i,r);
 end;
begin
   read(n,m);
   for i:=1 to n do read(a[1,i]);
   for i:=1 to n do a[2,i]:=i;
   for i:=1 to m do read(x[1,i],x[2,i]);
   qSort1(1,n);
   for i:=1 to n do a[3,i]:=i mod 2;
   for i:=1 to n do
      for j:=1 to n do
         if (a[2,j]=i) then write(a[3,j],' ');
   writeln;
end.

var     i,n,m,x,u,v:longint;
        a,b:array[1..100] of longint;
        d:array[1..100] of longint;

procedure quicksort(L,H:longint);
var     i,j,x,tmp:longint;
begin
        i:=L;
        j:=H;
        x:=a[(L+H) div 2];
        repeat
             while a[i]<x do inc(i);
             while a[j]>x do dec(j);
             if i<=j then
                begin
                     tmp:=a[i];
                     a[i]:=a[j];
                     a[j]:=tmp;
                     inc(i);
                     dec(j);
                end;
        until i>j;
        if L<j then quicksort(L,j);
        if i<H then quicksort(i,H);
end;

BEGIN
        readln(n,m);
        for i:=1 to n do
        read(b[i]);
        a:=b;
        quicksort(1,n);
        for i:=1 to n do
            if i mod 2=1 then d[a[i]]:=0 else d[a[i]]:=1;
        for i:=1 to n do
            write(d[b[i]],' ');
END.

var
  n,i,j : longint;
  a,b,c : array[0..150] of longint;

begin
  readln(n,i);
  for i:=1 to n do begin read(a[i]); b[i]:=i; end;
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i] > a[j] then begin
        a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0];
        a[0]:=b[i]; b[i]:=b[j]; b[j]:=a[0];
      end;
  for i:=1 to n do c[b[i]]:=i mod 2;
  for i:=1 to n do write(c[i],' '); writeln;
end.

var a,x,b:array[0..101]of longint;
    m,n,p,q,i:longint;

 procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
    begin
  readln(n,m);
  for i:= 1 to n do begin read(a[i]); b[i]:=a[i] end;
   sort(1,n);
  for i:= 1 to n do
    if i mod 2 = 1 then x[a[i]]:=0 else x[a[i]]:=1;
  for i:= 1 to m do
   readln(p,q);
  for i:= 1 to n do
   write(x[b[i]],' ');
end.

Var n,m,i,o:longint;
    x,l,r,a,b:array [0..1000] of longint;
 begin
  read(n,m);
  for i:=1 to n do
   read(x[i]);
  for i:=1 to m do
   read(l[i],r[i]);
  for i:=1 to n do
   a[x[i]]:=i;
  for i:=1 to 100 do
   begin
    if a[i]<>0 then inc(o);
    if o mod 2=0 then b[a[i]]:=0
                 else b[a[i]]:=1;
   end;
  for i:=1 to n do
   write(b[i],' ');
  writeln;
 end.

{$MODE OBJFPC}
Program onlylove;
uses math;
type pt = record x , y : longint; end;
var n , m , i , f , j : longint;
    l , r : array[0..101]  of longint;
    a : array[0..101]  of pt;
    ans : array[0..101] of longint;
procedure swap(var x ,y : pt) ;
  var tmp : pt;
  begin
    tmp := x;
    x   := y;
    y   := tmp;
  end;
begin
  Readln(n,m);
  for i:=1 to n do read(a[i].x);
  for i:=1 to n do a[i].y  := i;
  for i:=1 to m do Readln(l[i],r[i]);
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i].x > a[j].x then
        swap(a[i],a[j]);
  f := 1;
  for i:=1 to n do
    begin
      a[i].x := f;
      f := 1 - f;
    end;
   for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i].y > a[j].y then
        swap(a[i],a[j]);
   for i:=1 to n do Write(a[i].x,' ');
end.

var
 c:array[1..100]of char;
 x,y,a,b:array[1..100]of longint;
 i,j,max1,max,n,m,maxj:longint;
begin
 readln(n,m);
 for i:=1 to n do read(a[i]);
 for i:=1 to n do b[i]:=i;
 readln;
 for i:=1 to n do readln(x[i],y[i]);
 for i:=1 to n do
 begin
  max:=maxlongint;
  for j:=i to n do if (a[j]<max) then
  begin
   max:=a[j];
   maxj:=j;
   max1:=b[j];
  end;
  a[maxj]:=a[i];
  a[i]:=max;
  b[maxj]:=b[i];
  b[i]:=max1;
 end;
 for i:=1 to n do if i mod 2=0 then c[i]:='0' else c[i]:='1';
 for i:=1 to n do for j:=1 to n do if b[j]=i then write(c[j],' ');
end.

uses
    math;

var
    b,y,x:array[0..1000] of longint;
    i,j,n,m,temp,ans1,l,r,ans2:longint;

Begin
    read(n,m);
    for i:=1 to n do
        begin
            read(x[i]);
            y[i]:=i;
        end;
    for i:=1 to n do
        for j:=i+1 to n do
            if x[i] > x[j] then
                begin
                    temp:=x[i];
                    x[i]:=x[j];
                    x[j]:=temp;
                    temp:=y[i];
                    y[i]:=y[j];
                    y[j]:=temp;
                end;
    for i:=1 to n do
        b[y[i]]:=i mod 2;
    for i:=1 to n do
        write(b[i],' ');
end.

var
 x1,a,x,l,r:array[0..100]of longint;
 j,i,sum,n,m:longint;
 f:boolean;

 procedure check;
 begin
  for i:=1 to m do
  begin
   sum:=0;
   for j:=l[i] to r[i] do if a[j]<>-1 then
   begin
    if a[j]=0 then dec(sum) else inc(sum);
   end;
   if abs(sum)>1 then f:=true;
  end;
 end;

begin
 readln(n,m);
 for i:=1 to n do read(x[i]);
 x1:=x;
 for i:=1 to n do for j:=i+1 to n do if x[j]<x[i] then
 begin
  sum:=x[i];
  x[i]:=x[j];
  x[j]:=sum;
 end;
 readln;
 for i:=1 to m do readln(l[i],r[i]);
 fillchar(a,sizeof(a),255);

 for i:=1 to n do if odd(i) then a[x[i]]:=0 else a[x[i]]:=1;
 f:=false;
 check;
 if not f then
 begin
  for i:=1 to n do write(a[x1[i]],' ');
  halt;
 end;
 writeln(-1);
end.

{$r-,s-,q-,i-,o+}
var
  n,m,i,j,x:longint;
  a,t,l,r,h:array [0..20000] of longint;
begin
  readln(n,m);
  for i:=1 to n do read(a[i]);
  for i:=1 to m do readln(l[i],r[i]);
  for i:=1 to n do h[i]:=i;
  for i:=1 to n do
    for j:=1 to n-1 do
      if (a[i]<a[j]) then begin x:=a[i]; a[i]:=a[j]; a[j]:=x; x:=h[i]; h[i]:=h[j]; h[j]:=x; end;
  t[h[1]]:=1;
  for i:=2 to n do t[h[i]]:=(t[h[i-1]]+1) mod 2;
  for i:=1 to n do write(t[i],' ');
end.

const
        fi='';//'cf430a.inp';
        fo='';//'cf430a.out';
var
        a,b:array[0..100] of longint;
        i,x,n,dem:longint;
begin
        assign(input,fi);reset(input);
        assign(output,fo);rewrite(output);
        readln(n);
        for i:=1 to n do begin read(x);a[x]:=i; end;
        for i:=0 to 100 do
         if a[i]<>0 then
                begin
                        inc(dem);
                        b[a[i]]:=dem mod 2;
                end;
        for i:=1 to n do write(b[i],' ');
        close(input);
        close(output);
end.

var n, m, x, y, i: longint;
    a, b, z: array [1..100] of longint;
procedure sort(l, r: longint);
var i, j, x, y: longint;
begin
        i := l;
        j := r;
        x := a[random(r - l) + l + 1];
        while i <= j do
        begin
                while a[i] < x do
                        inc(i);
                while x < a[j] do
                        dec(j);
                if i <= j then
                begin
                        y := a[i];
                        a[i] := a[j];
                        a[j] := y;
                        y := b[i];
                        b[i] := b[j];
                        b[j] := y;
                        inc(i);
                        dec(j);
                end;
        end;
        if l < j then
                sort(l, j);
        if i < r then
                sort(i, r);
end;
begin
        readln(n, m);
        for i := 1 to n do
        begin
                read(a[i]);
                b[i] := i;
        end;
        for i := 1 to m do
                readln(x, y);
        sort(1, n);
        for i := 1 to n do
                z[b[i]] := i and 1;
        for i := 1 to n do
                write(z[i], ' ');
end.

const   fi='';
var     inp:text;
        i,n,m,j,t:longint;
        a,p:array[1..1000] of longint;
begin
        assign(inp,fi);reset(inp);
        readln(inp,n,m);
        for i:=1 to n do read(inp,a[i]);
        for i:=1 to n do p[i]:=i;
        for i:=1 to n do
        for j:=i+1 to n do
        if a[i]>a[j] then begin
                t:=a[i];a[i]:=a[j];a[j]:=t;
                t:=p[i];p[i]:=p[j];p[j]:=t;
        end;
        for i:=1 to n do a[p[i]]:=i mod 2;
        for i:=1 to n do write(a[i],' ');
end.

type    int =   longint;
var i,n,m,j,t   :   int;
    x,p,c   :   array[1..101]   of  int;
begin
    readln(n,m);
    for i:=1 to n do
        begin
            read(x[i]); p[i] := i;
        end;
    for i:=1 to n-1 do
        for j:=i+1 to n do
            if X[i]>X[j] then
                begin
                    t := X[i]; X[i] := X[j]; X[j] := t;
                    t := P[i]; P[i] := P[j]; P[j] := t;
                end;
    for i:=1 to n do C[P[i]] := i mod 2;
    for i:=1 to n do write(C[i],' ');
end.

var
    n,i,m,k,ok :Longint;
    free,cr,x  :Array[0..200] of Longint;
begin
    read(n,m);
    for i:=1 to N do
    begin
        read(k);
        x[i]:=k;
        free[k]:=1;
    end;

    ok:=0;
    for i:=0 to 100 do
        if free[i]=1 then
        begin
            if ok=0 then cr[i]:=1;
            ok:=1-ok;
        end;
    for i:=1 to N do write(cr[x[i]],' ');
end.

type    te = record
        x, y : integer;
        end;
var     a : array[1..105] of te;
        n, m : integer;
        ispoint : array[1..105] of boolean;
        kq, b : array[1..105] of integer;
procedure enter;
        var     i : integer;
        begin
          readln(n, m);
          fillchar(ispoint, sizeof(ispoint), false);
          for i := 1 to 100 do b[i] := -1;
          for i := 1 to n do
                begin
                  read(kq[i]);
                   ispoint[kq[i]] := true;
                end;
          for i := 1 to m do
                readln(a[i].x, a[i].y);
        end;
procedure swap(var x, y : te);
        var     t : te;
        begin
          t := x;
          x := y;
          y := t;
        end;
procedure sort(l, r : integer);
        var     g, g2, i, j, t : integer;
        begin
          if l >= r then exit;
          t := L + random(R-L) + 1;
          g := a[t].x;
          g2 := a[t].y;
          i := l; j := r;
          repeat
            while (a[i].x < g) or ((a[i].x=g) and (a[i].y<g2)) do inc(i);
            while (a[j].x > g) or ((a[j].x=g) and (a[j].y<g2)) do dec(j);
            if i <= j then
                begin
                  if i < j then swap(a[i], a[j]);
                  inc(i); dec(j);
                end;
          until i > j;
          sort(l, j); sort(i, r);
        end;
procedure process;
        var     i, j, t : integer;
        begin
          randomize;
          sort(1, m);
          for i := 1 to m do
                begin
                  t := 0;
                  for j := a[i].x to a[i].y do
                        if ispoint[j] then
                                begin
                                  if b[j] = -1 then
                                        b[j] := 1 - t;
                                  t := b[j];
                                end;
                end;
        end;
procedure print;
        var     i : integer;
        begin
          for i := 1 to n do
                if b[kq[i]] > -1 then write(b[kq[i]],' ')
                else
                        write(0,' ');
        end;
begin
        enter;
        process;
        print;
end.

var
 i,n,m,j,t:longint;
 a,p:array[1..1000] of longint;
begin
 readln(n,m);
 for i:=1 to n do
  read(a[i]);
 for i:=1 to n do
  p[i]:=i;
 for i:=1 to n do
 for j:=i+1 to n do
 if a[i]>a[j] then
 begin
  t:=a[i];a[i]:=a[j];a[j]:=t;
  t:=p[i];p[i]:=p[j];p[j]:=t;
 end;
 for i:=1 to n do
  a[p[i]]:=i mod 2;
 for i:=1 to n do
  write(a[i],' ');
end.

const maxn = 105;
var n,m:longint;
    x,y,ans:array[0..maxn] of longint;
procedure init();
  var i,j,l,r,tmp,now:longint;
  begin
    readln(n,m); for i:=1 to n do begin read(x[i]); y[i]:=i; end;
    for i:=1 to m do readln(l,r);
    for i:=1 to n-1 do
      for j:=i+1 to n do
        if x[y[i]]>x[y[j]] then begin
          tmp:=y[i]; y[i]:=y[j]; y[j]:=tmp;
        end;
    now:=1;
    for i:=1 to n do begin
      ans[y[i]]:=now; now:=1-now;
    end;
  end;
procedure print();
  var i:longint;
  begin
    for i:=1 to n do write(ans[i],' '); writeln();
  end;
begin
  init();
  print();
end.

const
    fi='';
    fo='';
var
    a,b,d:array[0..1000]of integer;

procedure main;
var i,j,x,n,m:integer;
begin
    assign(input,fi);   reset(input);
    assign(output,fo);  rewrite(output);

    read(n,m);
    for i:=1 to n do
      begin
        read(a[i]);
        b[i]:=a[i];
      end;

    for i:=0 to 100 do
        d[i]:=2;

    for i:=1 to n-1 do
        for j:=i+1 to n do
            if a[i]>a[j] then
                begin
                    x:=a[i];
                    a[i]:=a[j];
                    a[j]:=x;
                end;
    for i:=1 to n do
        if odd(i) then d[a[i]]:=0
        else d[a[i]]:=1;

    for i:=1 to n do
         write(d[b[i]],' ');

    close(input);       close(output);
end;

BEGIN
    main;
END.

const fi='';
     fo='';
type mang=array[1..100] of integer;
var
a,b,k:mang;
i,j,n,m:integer;

procedure hoanvi(var x,y:integer);
var t:integer;
begin
  t:=x;
  x:=y;
  y:=t;
end;

procedure quicksort( var a:mang;lo,hi:integer);
procedure sort(l,r:integer);
var i,j,x:integer;
begin
 i:=l;j:=r;
 x:=a[(l+r) div 2];
 repeat
 while a[i]<x do inc(i);
 while x<a[j] do dec(j);
 if i<=j then begin
 hoanvi(a[i],a[j]);
 inc(i);
 dec(j);
 end;
 until i>j;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
 end;
 begin
  sort(lo,hi);
 end;

begin
assign(input,fi);reset(input);
assign(output,fo);rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
k[i]:=a[i];
end;
quicksort(a,1,n);

for i:=1 to n do if i mod 2=1 then b[a[i]]:=1;
for i:=1 to n do write(b[k[i]],' ');

readln;
for i:=1 to m do readln(a[i],b[i]);

close(input);
close(output);
end.

var n, m, i, j, l, r, t: byte; x, y, res: array[1..100] of byte;
begin
  read(n,m);
  for i:=1 to n do begin read(x[i]); y[i]:=i; end;
  for i:=1 to n-1 do for j:=1 to n-i do if x[j]>x[j+1] then
  begin
    t:=x[j]; x[j]:=x[j+1]; x[j+1]:=t;
    t:=y[j]; y[j]:=y[j+1]; y[j+1]:=t;
  end;
  for i:=1 to n do
    res[y[i]]:=i mod 2;
  for i:=1 to m do read(l,r);
  for i:=1 to n do write(res[i], ' ');
  writeln;
end.

type
  block = record
    ans,num,data:longint;
  end;

var
  n,x,i,m,j,z:longint;
  a:array[1..100] of block;
  t:block;

begin
  read(n,m);
  for i:=1 to n do
    begin
      read(a[i].data);
      a[i].num:=i;
    end;
  for i:=1 to n do
    for j:=i+1 to n do
      begin
        if a[i].data>a[j].data then
          begin
            t:=a[i];
            a[i]:=a[j];
            a[j]:=t;
          end;
      end;
  for i:=1 to n do
    begin
      a[i].ans:=z;
      z:=1-z;
    end;
  for i:=1 to n do
    for j:=i+1 to n do
      begin
        if a[i].num>a[j].num then
          begin
            t:=a[i];
            a[i]:=a[j];
            a[j]:=t;
          end;
      end;
  for i:=1 to n do
    write(a[i].ans,' ');
end.

type point=record
                gt,tt:byte
           end;
var n,i,j:byte; x:array[1..100] of point; tg:point;
begin
        readln(n,i);
        for i:=1 to n do
        with x[i] do
        begin
                read(gt);
                tt:=i
        end;
        for i:=1 to n-1 do
        for j:=i+1 to n do
        if x[i].gt>x[j].gt then
        begin
                tg:=x[i]; x[i]:=x[j]; x[j]:=tg
        end;
        for i:=1 to n do
        if i mod 2=1 then x[i].gt:=0
        else x[i].gt:=1;
        for i:=1 to n-1 do
        for j:=i+1 to n do
        if x[i].tt>x[j].tt then
        begin
                tg:=x[i]; x[i]:=x[j]; x[j]:=tg
        end;
        for i:=1 to n do write(x[i].gt,' ')
end.

program task1;
const nmax = 109;

type
	seg = record
		l, r : longint;
	end;
	pair = record
		v : longint;
		id:longint;
	end;

	tar = array [1..nmax] of pair;
	par = array [1..nmax] of seg;

	Procedure Qsort(var a : tar; l, r : longint);
	var k, j : longint;
	mid, w : pair;
	begin
		k:=l;
		j:=r;
		mid:=a[l+random(r-l+1)];
		while (k<=j) do begin
			while (a[k].v < mid.v) do inc(k);
			while (a[j].v > mid.v) do dec(j);
			if (k<=j) then begin
				w:=a[k]; a[k]:=a[j]; a[j]:=w;
				inc(k); dec(j);
			end;
		end;
		if (l<j) then Qsort(a,l,j);
		if (r>k) then Qsort(a,k,r);
	end;

	Procedure QsortS(var a : par; l, r : longint);
	var k, j : longint;
	mid, w : seg;
	begin
		k:=l;
		j:=r;
		mid:=a[l+random(r-l+1)];
		while (k<=j) do begin
			while (a[k].l < mid.l) or ( (a[k].l = mid.l) and (a[k].r < mid.r) ) do inc(k);
			while (a[j].l > mid.l) or ( (a[j].l = mid.l) and (a[j].r > mid.r) ) do dec(j);
			if (k<=j) then begin
				w:=a[k]; a[k]:=a[j]; a[j]:=w;
				inc(k); dec(j);
			end;
		end;
		if (l<j) then QsortS(a,l,j);
		if (r>k) then QsortS(a,k,r);
	end;

var n, m, i, j, last, rcnt, bcnt : longint;
a : tar;
b : par;
c : array [0..nmax] of longint;
begin
	randseed:=234234;
	readln(n,m);
	for i:=1 to n do begin
		Read(a[i].v);
		a[i].id:=i;
	end;

	readln();
	for i:=1 to m do begin
		Readln(b[i].l,b[i].r);
	end;

	Qsort(a,1,n);

	for i:=1 to n do begin
		if odd(i) then begin
			c[a[i].id]:=0;
		end else begin
			c[a[i].id]:=1;
		end;
	end;
	for i:=1 to n do begin
		Write(c[i],' ');
	end;
	writeln();
	{
	QsortS(b,1,m);

	for i:=1 to n do c[i]:=-1;

	for i:=1 to m do begin
		rcnt:=0; bcnt:=0;
		last:= -1;
		for j:=1 to n do begin

			if (a[j] >= b[i].l) and (a[j] <= b[i].r) then begin
				if c[j] = -1 then begin
					if rcnt < bcnt then begin
						c[j]:=0;
						inc(rcnt);
						last:=0;
					end else if rcnt > bcnt then begin
						c[j]:=1;
						inc(bcnt);
						last:=1;
					end else begin
						if last = 0 then begin
							c[j]:=1;
							inc(bcnt);
							last:=1;
						end else begin
							c[j]:=0;
							inc(rcnt);
							last:=0;
						end;
					end;
				end else begin
					if c[j] = 0 then inc(rcnt)
					else inc(bcnt);
					last:=c[j];
				end;
			end;

		end;
		if abs(rcnt-bcnt)>1 then begin
			Writeln('-1');
			Exit();
		end;
	end;

	for i:=1 to n do begin
		if c[i] = -1 then c[i]:=0;
		Write(c[i],' ');
	end;
	writeln();
	}
end.

uses math;
const Nmax=1000;
var a: array[0..Nmax] of longint;
     n,m,k,i,j,x,y,l,r: longint;

begin
//  assign(input,'input.txt'); reset(input);
//  assign(output,'output.txt'); rewrite(output);

    read(n,m);

    for i:=1 to n do   read(x);
    for i:=1 to m do   read(l,r);

    for i:=1 to n do
      if i mod 2 = 0 then write('0 ') else write('1 ');

end.

  program Pr1;

{$APPTYPE CONSOLE}

label 1,2,3,4;
const modul=100000007;  besk=100000000;  besk1=1000000000000;  eps=1e-10;
type double=extended;
mas=array[-10..2000000] of int64; mass=^mas;
var bb,n1,n2,kol,jj,n,k,i,j: longint;
fact,a,d,ot2,numi,numj,newobr,obr,pred,next,b,c:array[-1000..2000000] of int64;
zan,pr: array[0..5000000] of boolean;
x,y:array[-10..200000] of double;
sss1,sss2,sss:string;
per:mas;
flag:boolean;
p,r,period,l,mmod,pos,iot,jot,kk,pmin,imin,pmax,imax,i1,i2,j1,j2,qq,pp,iii,p1,p2,kolelem,tt,ot,s,t,al,m:int64;
pole1:array[-10..600,-10..600] of char;
otch:array[0..1000000] of char;
beta,otold,otnew,x2,x0,x1,aa,cc:double;
dd5,dd6,dd2,dd3,dd4,dd1,pole,cena:array[-10..1100,-10..1100] of int64;
marked:array[-10..60000] of boolean;
napx,napy: array[-10..600] of  longint;
function max(a,b:int64):int64; begin max:=a;if b>a then max:=b; end;
function min(a,b:int64):int64; begin min:=a;if b<a then min:=b; end;

function step(a,k:int64):int64; var p,t:int64;
begin
 if k=0 then step:=1 else
 begin;
    if odd(k) then step:=step(a,k-1)*a mod modul else
      begin
        t:=k div 2; p:=step(a,t); step:=p*p mod modul;
      end;

 end;
end;

begin
 {reset(input,'F:\Projects\input.txt');close(input);
 rewrite(output,'F:\Projects\output.txt');close(output);
  }

  read(n,k,r);
 for i:=1 to n do read(a[i]);
 for i:=1 to n do b[i]:=i;
 for i:=1 to n do for j:=1 to n-1 do if a[j]>a[j+1] then
   begin t:=a[j]; a[j]:=a[j+1];a[j+1]:=t;   t:=b[j]; b[j]:=b[j+1];b[j+1]:=t;        end;

 for i:=1 to n do c[b[i]]:=i mod 2;
 for i:=1 to n do write(c[i],' ');

   1: close (output);
end.

       program Pr1;

{$APPTYPE CONSOLE}

label 1,2,3,4;
const modul=100000007;  besk=100000000;  besk1=1000000000000;  eps=1e-10;
type double=extended;
mas=array[-10..2000000] of int64; mass=^mas;
var bb,n1,n2,kol,jj,n,k,i,j: longint;
fact,a,d,ot2,numi,numj,newobr,obr,pred,next,b,c:array[-1000..2000000] of int64;
zan,pr: array[0..5000000] of boolean;
x,y:array[-10..200000] of double;
sss1,sss2,sss:string;
per:mas;
flag:boolean;
p,r,period,l,mmod,pos,iot,jot,kk,pmin,imin,pmax,imax,i1,i2,j1,j2,qq,pp,iii,p1,p2,kolelem,tt,ot,s,t,al,m:int64;
pole1:array[-10..600,-10..600] of char;
otch:array[0..1000000] of char;
beta,otold,otnew,x2,x0,x1,aa,cc:double;
dd5,dd6,dd2,dd3,dd4,dd1,pole,cena:array[-10..1100,-10..1100] of int64;
marked:array[-10..60000] of boolean;
napx,napy: array[-10..600] of  longint;
function max(a,b:int64):int64; begin max:=a;if b>a then max:=b; end;
function min(a,b:int64):int64; begin min:=a;if b<a then min:=b; end;

function step(a,k:int64):int64; var p,t:int64;
begin
 if k=0 then step:=1 else
 begin;
    if odd(k) then step:=step(a,k-1)*a mod modul else
      begin
        t:=k div 2; p:=step(a,t); step:=p*p mod modul;
      end;

 end;
end;

begin
{ reset(input,'F:\Projects\input.txt');close(input);
 rewrite(output,'F:\Projects\output.txt');close(output);
 }

  read(n);
for i:=1 to n do write(i mod 2,' ');

   1: close (output);
end.

var a:array[0..100] of integer;
    x:array[1..100] of integer;
    n,i,m:integer;
begin
    for i:=0 to 100 do
       if i mod 2=0 then a[i]:=0 else a[i]:=1;
    readln(n,m);
    for i:=1 to n do read(x[i]);
    for i:=1 to n do write(a[x[i]],' ');
end.

program points;
var a,b,mau:array[1..1000] of longint;
    m,n,i,j,x,y,z:longint;
begin
     read(n);
     read(m);
     for i:=1 to n do
     begin
          read(a[i]);
     end;
     for i:=1 to n do
     begin
          b[i]:=a[i];
     end;
     for i:=1 to m do
     begin
          read(x);
          read(y);
     end;
     for i:=1 to n-1 do
     begin
          for j:=i+1 to n do
          begin
               if a[i] > a[j] then
               begin
                    z:=a[i];
                    a[i]:=a[j];
                    a[j]:=z;
               end;
          end;
     end;
     for i:=1 to n do
     begin
          if i mod 2 = 0 then
          begin
               mau[a[i]]:=0;
          end;
          if (i mod 2 <> 0) then
          begin
               mau[a[i]]:=1;
          end;
     end;
     for i:=1 to n do
     begin
          write(mau[a[i]]);
     end;

end.

program points;
var a,b,mau:array[1..1000] of longint;
    m,n,i,j,x,y,z:longint;
begin
     read(n);
     read(m);
     for i:=1 to n do
     begin
          read(a[i]);
     end;
     for i:=1 to n do
     begin
          b[i]:=a[i];
     end;
     for i:=1 to m do
     begin
          read(x);
          read(y);
     end;
     for i:=1 to n do
     begin
          if a[i] mod 2 = 0 then write(1);
          if a[i] mod 2 <>0 then write(0);
          write(' ');
     end;

end.

program points;
var a,b,mau:array[1..1000] of longint;
    m,n,i,j,x,y,z:longint;
begin
     read(n);
     read(m);
     for i:=1 to n do
     begin
          read(a[i]);
     end;
     for i:=1 to n do
     begin
          b[i]:=a[i];
     end;
     for i:=1 to m do
     begin
          read(x);
          read(y);
     end;
     for i:=1 to n-1 do
     begin
          for j:=i+1 to n do
          begin
               if a[i] > a[j] then
               begin
                    z:=a[i];
                    a[i]:=a[j];
                    a[j]:=z;
               end;
          end;
     end;
     for i:=1 to n do
     begin
          if i mod 2 = 0 then
          begin
               mau[a[i]]:=0;
          end;
          if (i mod 2 <> 0) then
          begin
               mau[a[i]]:=1;
          end;
     end;
     for i:=1 to n do
     begin
          write(mau[a[i]],' ');
     end;

end.

Var a,b,c,kol:array[1..1000000] of longint;
    i,j,k,m,l,o,p,n:longint;

    procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

 Begin
  read(n,m);
  for i:=1 to n do begin read(a[i]); inc (kol[a[i]]); end;
  for i:=1 to m do read(b[i],c[i]);
  sort(1,n);
  for i:=0 to 100 do begin
  if kol[i]<>0 then begin  inc(j);
  if j mod 2=0 then write('1 ' )
  else write('0 ');  end; end;

 end.

Var a,b,c,kol:array[1..1000000] of longint;
    i,j,k,m,l,o,p,n:longint;
 Begin
  read(n,m);
  for i:=1 to n do read(a[i]);
  for i:=1 to m do read(b[i],c[i]);
  for i:=1 to n do begin
  if i mod 2=0 then write('1 ' )
  else write('0 ');  end;
 end.

Var a,b,c,kol,ans:array[1..1000000] of longint;
    i,j,k,m,l,o,p,n:longint;

    procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                y:=kol[i];
                kol[i]:=kol[j];
                kol[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

    procedure ssort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=kol[(l+r) div 2];
         repeat
           while kol[i]<x do
            inc(i);
           while x<kol[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                 y:=kol[i];
                kol[i]:=kol[j];
                kol[j]:=y;
                 y:=ans[i];
                ans[i]:=ans[j];
                ans[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           ssort(l,j);
         if i<r then
           ssort(i,r);
      end;

 Begin
  read(n,m);
  for i:=1 to n do begin read(a[i]); kol[i]:=i;; end;
  for i:=1 to m do read(b[i],c[i]);
  sort(1,n);
  for i:=1 to n do begin ans[i]:=i mod 2; end;
  ssort(1,n);
  for i:=1 to n do write(a[i],' ')
 end.

program abc;
var n,m,a,b,i:longint;
begin
 read(n,m);
 for i:=1 to n do
  read(a);
  for i:=1 to m do
   read(a,b);
 for i:=1 to n do
  if i mod 2=0 then write(1)
  else write(0,' ');
end.

program abc;
var n,m,a,b,i:longint;
begin
 read(n,m);
 for i:=1 to n do
  read(a);
  for i:=1 to m do
   read(a,b);
 for i:=1 to n do
  if i mod 2=0 then write(1,' ')
  else write(0,' ');
end.

program abc;
var n,m,a,b,i:longint;
begin
 read(n,m);
 for i:=1 to n do
  read(a);
  for i:=1 to m do
   read(a,b);
 for i:=1 to n do
  write(i mod 2,' ');
end.

var
   n,m,i,j,g : longint;
   x : array [1..2,1..100] of longint;
   a : array [1..3,1..100] of longint;
procedure qSort1(l,r : longint);
 var k,i,j,y:longint;
 begin
    i:=l;
    j:=r;
    k:=a[1,(l+r) div 2];
    repeat
       while a[1,i]<k do inc(i);
       while a[1,j]>k do dec(j);
       if i<=j then
          begin
             y:=a[1,i]; a[1,i]:=a[1,j]; a[1,j]:=y;
             y:=a[2,i]; a[2,i]:=a[1,j]; a[2,j]:=y;
             inc(i); dec(j);
          end;
    until i>j;
    if l<j then qsort1(l,j);
    if i<r then qsort1(i,r);
 end;
begin
   read(n,m);
   for i:=1 to n do read(a[1,i]);
   for i:=1 to n do a[2,i]:=i;
   for i:=1 to m do read(x[1,i],x[2,i]);
   qSort1(1,n);
   for i:=1 to n do a[3,i]:=i mod 2;
   for i:=1 to n do
      for j:=1 to n do
         if (a[2,j]=i) then write(a[3,j],' ');
   writeln;
end.

var    i,n:longint;
BEGIN
    read(n);
    for i:=1 to n do
        if i mod 2=1 then write(1,' ') else write(0,' ');
END.

var    i,n:longint;
BEGIN
    read(n);
    for i:=1 to n do
        if i mod 2=1 then write(0,' ') else write(1,' ');
END.

var     i,n,m,x,u,v:longint;
BEGIN
        readln(n,m);
        for i:=1 to n do read(x);
        readln;
        for i:=1 to m do readln(u,v);
        for i:=1 to n do
            if i mod 2=1 then write(0,' ')
            else write(1,' ');
END.

var
  n,i : longint;

begin
  readln(n,i);
  for i:=1 to n do write(i mod 2,' '); writeln;
end.

var a,x,l,r,kq:array[0..101] of integer;
    kt:array[0..101] of boolean;
    i,j,n,m:integer;
begin
  readln(n,m);
  for i:= 1 to n do
  read(x[i]);
  fillchar(kt,sizeof(kt),false);
  for i:= 1 to n do kq[x[i]]:=-1;
   for i:= 1 to m do
     readln(l[i],r[i]);
for i:= 1 to n do
  for j:= 1 to m do
      if (x[i]>=l[j]) and (x[i]<=r[j]) and (not kt[i]) then
        begin
        kt[i]:=true;
         if (x[i-1]=0) then kq[i]:=1 else kq[i]:=0;
        end;

for i:= 1 to n do
    write(kq[i],' ');
end.

var a,x,y:array[0..101]of longint;
    m,n,p,q,i:longint;
begin
  readln(n,m);
  for i:= 1 to n do read(x[i]);
  for i:= 1 to m do
   readln(p,q);
  for i:= 0 to 100 do
   if i mod 2 = 0 then a[i]:=0 else a[i]:=1;
  for i:= 1 to n do
   write(a[x[i]],' ');
end.

Var n,m,i:longint;
    x,l,r:array [0..1000] of longint;
 begin
  read(n,m);
  for i:=1 to n do
   read(x[i]);
  for i:=1 to m do
   read(l[i],r[i]);
  for i:=1 to n do
   if i mod 2=0 then write(0,' ')
                else write(1,' ');
  writeln;

 end.

uses
    math;

var
    b,x:array[0..1000] of longint;
    i,j,n,m,temp,ans1,l,r,ans2:longint;

Begin
    read(n,m);
    for i:=1 to n do
        read(x[i]);
    for i:=1 to n do
        for j:=i+1 to n do
            if x[i] > x[j] then
                begin
                    temp:=x[i];
                    x[i]:=x[j];
                    x[j]:=temp;
                end;
    for i:=1 to n do
        b[i]:=i mod 2;
    for i:=1 to m do
        begin
            read(l,r);
            ans1:=0; ans2:=0;
            for j:=1 to n do
                if (x[j] >= l) and (x[j] <= r) then
                    begin
                        if b[j] = 1 then    inc(ans2)
                        else                inc(ans1);
                    end;
            if  not (abs(ans1-ans2) <= 1) then
                begin
                    writeln(-1);
                    halt;
                end;
        end;
    for i:=1 to n do
        write(b[i],' ');
end.

var
 a,x,l,r:array[0..100]of longint;
 j,i,sum,n,m:longint;
 f:boolean;

 procedure check;
 begin
  for i:=1 to m do
  begin
   sum:=0;
   for j:=l[i] to r[i] do if a[j]<>-1 then
   begin
    if a[j]=0 then dec(sum) else inc(sum);
   end;
   if abs(sum)>1 then f:=true;
  end;
 end;

begin
 readln(n,m);
 for i:=1 to n do read(x[i]);
 for i:=1 to n do for j:=i+1 to n do if x[j]>x[i] then
 begin
  sum:=x[i];
  x[i]:=x[j];
  x[j]:=sum;
 end;
 readln;
 for i:=1 to m do readln(l[i],r[i]);
 fillchar(a,sizeof(a),255);

 for i:=1 to n do if odd(i) then a[x[i]]:=0 else a[x[i]]:=1;
 check;
 if not f then
 begin
  for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');
  halt;
 end;

 f:=false;
 for i:=1 to n do if odd(i) then a[x[i]]:=1 else a[x[i]]:=0;
 check;
 if not f then
 begin
  for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');
  halt;
 end;
 writeln(-1);
end.

var
 a,x,l,r:array[0..100]of longint;
 j,i,sum,n,m:longint;
 f:boolean;

 procedure check;
 begin
  for i:=1 to m do
  begin
   sum:=0;
   for j:=l[i] to r[i] do if a[j]<>-1 then
   begin
    if a[j]=0 then dec(sum) else inc(sum);
   end;
   if abs(sum)>1 then f:=true;
  end;
 end;

begin
 readln(n,m);
 for i:=1 to n do read(x[i]);
 for i:=1 to n do for j:=i+1 to n do if x[j]<x[i] then
 begin
  sum:=x[i];
  x[i]:=x[j];
  x[j]:=sum;
 end;
 readln;
 for i:=1 to m do readln(l[i],r[i]);
 fillchar(a,sizeof(a),255);

 for i:=1 to n do if odd(i) then a[x[i]]:=0 else a[x[i]]:=1;
 f:=false;
 check;
 if not f then
 begin
  for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');
  halt;
 end;
 writeln(-1);
end.

var
 a,x,l,r:array[0..100]of longint;
 j,i,sum,n,m:longint;
 f:boolean;

 procedure check;
 begin
  for i:=1 to m do
  begin
   sum:=0;
   for j:=l[i] to r[i] do if a[j]<>-1 then
   begin
    if a[j]=0 then dec(sum) else inc(sum);
   end;
   if abs(sum)>1 then f:=true;
  end;
 end;

begin
 readln(n,m);
 for i:=1 to n do read(x[i]);
 readln;
 for i:=1 to m do readln(l[i],r[i]);
 fillchar(a,sizeof(a),255);

 for i:=1 to n do if odd(i) then a[x[i]]:=0 else a[x[i]]:=1;
 check;
 if not f then
 begin
  for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');
  halt;
 end;

 f:=false;
 for i:=1 to n do if odd(i) then a[x[i]]:=1 else a[x[i]]:=0;
 check;
 if not f then
 begin
  for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');
  halt;
 end;
 writeln(-1);
end.

{$r-,s-,q-,i-,o+}
var
  n,m,i:longint;
  a,t,l,r:array [0..20000] of longint;

  function ok():boolean;
    var i,j:longint; f:array [0..200,0..20] of longint;
      begin
        fillchar(f,sizeof(f),0);
        for i:=1 to n do
          for j:=1 to m do
            if (a[i]>=l[j]) and (a[i]<=r[j]) then
             inc(f[j,t[i]]);
        for i:=1 to m do
          if abs(f[i,0]-f[i,1])>1 then exit(false);
        exit(true);
      end;

begin
  readln(n,m);
  for i:=1 to n do read(a[i]);
  for i:=1 to m do readln(l[i],r[i]);
  t[1]:=0;
  for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;
  if (ok()) then
    begin
      for i:=1 to n do write(t[i],' ');
      halt(0);
    end;
  t[1]:=1;
  for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;
  if (ok()) then
    begin
      for i:=1 to n do write(t[i],' ');
      halt(0);
    end;
  writeln(-1);
end.

{$r-,s-,q-,i-,o+}
var
  n,m,i,j,x:longint;
  a,t,l,r:array [0..20000] of longint;
begin
  readln(n,m);
  for i:=1 to n do read(a[i]);
  for i:=1 to m do readln(l[i],r[i]);
  t[1]:=1;
  for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;
  for i:=1 to n do
    for j:=1 to n-1 do
      if (a[i]<a[j]) then begin x:=a[i]; a[i]:=a[j]; a[j]:=x; x:=t[i]; t[i]:=t[j]; t[j]:=x; end;
  for i:=1 to n do write(t[i],' ');
end.

{$r-,s-,q-,i-,o+}
var
  n,m,i:longint;
  a,t,l,r:array [0..20000] of longint;

  function ok():boolean;
    var i,j:longint; f:array [0..200,0..20] of longint;
      begin
        fillchar(f,sizeof(f),0);
        for i:=1 to n do
          for j:=1 to m do
            if (a[i]>=l[j]) and (a[i]<=r[j]) then
             inc(f[j,t[i]]);
        for i:=1 to m do
          if abs(f[i,0]-f[i,1])>1 then exit(false);
        exit(true);
      end;

begin
  readln(n,m);
  for i:=1 to n do read(a[i]);
  for i:=1 to m do readln(l[i],r[i]);
  t[1]:=0;
  for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;
  if (ok()) then
    begin
      for i:=1 to n do write(t[i],' ');
      halt(0);
    end;
  t[1]:=1;
  for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;
  for i:=1 to n do write(t[i],' ');
end.

const   fi='';
var     inp:text;
        i,n,m:longint;
begin
        assign(inp,fi);reset(inp);
        readln(inp,n,m);
        for i:=1 to n do write(i mod 2,' ');
end.

type    int =   longint;
var i,n,m   :   int;
begin
    readln(n,m);
    for i:=1 to n do write(i mod 2,' ');
end.

type    te = record
        x, y : integer;
        end;
var     a : array[1..105] of te;
        n, m : integer;
        ispoint : array[1..105] of boolean;
        kq, b : array[1..105] of integer;
procedure enter;
        var     i : integer;
        begin
          readln(n, m);
          fillchar(ispoint, sizeof(ispoint), false);
          for i := 1 to 100 do b[i] := -1;
          for i := 1 to n do
                begin
                  read(kq[i]);
                   ispoint[kq[i]] := true;
                end;
          for i := 1 to m do
                readln(a[i].x, a[i].y);
        end;
procedure swap(var x, y : te);
        var     t : te;
        begin
          t := x;
          x := y;
          y := t;
        end;
procedure sort(l, r : integer);
        var     g, g2, i, j, t : integer;
        begin
          if l >= r then exit;
          t := L + random(R-L) + 1;
          g := a[t].x;
          g2 := a[t].y;
          i := l; j := r;
          repeat
            while (a[i].x < g) or ((a[i].x=g) and (a[i].y<g2)) do inc(i);
            while (a[j].x > g) or ((a[j].x=g) and (a[j].y<g2)) do dec(j);
            if i <= j then
                begin
                  if i < j then swap(a[i], a[j]);
                  inc(i); dec(j);
                end;
          until i > j;
          sort(l, j); sort(i, r);
        end;
procedure process;
        var     i, j, t : integer;
        begin
          randomize;
          sort(1, m);
          for i := 1 to m do
                begin
                  t := 0;
                  for j := a[i].x to a[i].y do
                        if ispoint[j] then
                                begin
                                  if b[j] = -1 then
                                        b[j] := 1 - t;
                                  t := b[j];
                                end;
                end;
        end;
procedure print;
        var     i : integer;
        begin
          for i := 1 to n do
                write(b[kq[i]],' ');
        end;
begin
        enter;
        process;
        print;
end.

const
    fi='';
    fo='';

procedure main;
var i,n,m:integer;
begin
    assign(input,fi);   reset(input);
    assign(output,fo);  rewrite(output);

    read(n,m);
    for i:=1 to n do
        if odd(i) then write('0 ')
        else write('1 ');

    close(input);       close(output);
end;

BEGIN
    main;
END.

const fi='';
     fo='';
type mang=array[1..100] of integer;
var
a,b:mang;
i,j,n,m:integer;

procedure hoanvi(var x,y:integer);
var t:integer;
begin
  t:=x;
  x:=y;
  y:=t;
end;

procedure quicksort( var a:mang;lo,hi:integer);
procedure sort(l,r:integer);
var i,j,x:integer;
begin
 i:=l;j:=r;
 x:=a[(l+r) div 2];
 repeat
 while a[i]<x do inc(i);
 while x<a[j] do dec(j);
 if i<=j then begin
 hoanvi(a[i],a[j]);
 hoanvi(b[i],b[j]);
 inc(i);
 dec(j);
 end;
 until i>j;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
 end;
 begin
  sort(lo,hi);
 end;

begin
assign(input,fi);reset(input);
assign(output,fo);rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
readln;
if i mod 2=1 then b[i]:=1;
end;
quicksort(a,1,n);

for i:=1 to n do write(b[i],' ');
for i:=1 to m do readln(a[i],b[i]);

close(input);
close(output);
end.

const fi='';
     fo='';
type mang=array[1..100] of integer;
var
a,b:mang;
i,j,n,m:integer;

procedure hoanvi(var x,y:integer);
var t:integer;
begin
  t:=x;
  x:=y;
  y:=t;
end;

procedure quicksort( var a:mang;lo,hi:integer);
procedure sort(l,r:integer);
var i,j,x:integer;
begin
 i:=l;j:=r;
 x:=a[(l+r) div 2];
 repeat
 while a[i]<x do inc(i);
 while x<a[j] do dec(j);
 if i<=j then begin
 hoanvi(a[i],a[j]);
 hoanvi(b[i],b[j]);
 inc(i);
 dec(j);
 end;
 until i>j;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
 end;
 begin
  sort(lo,hi);
 end;

begin
assign(input,fi);reset(input);
assign(output,fo);rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
if i mod 2=0 then b[i]:=1;
end;
quicksort(a,1,n);

for i:=1 to n do write(b[i]);
for i:=1 to m do readln(a[i],b[i]);

close(input);
close(output);
end.

const fi='';
     fo='';
type mang=array[1..100] of integer;
var
a,b:mang;
i,j,n,m:integer;

procedure hoanvi(var x,y:integer);
var t:integer;
begin
  t:=x;
  x:=y;
  y:=t;
end;

procedure quicksort( var a:mang;lo,hi:integer);
procedure sort(l,r:integer);
var i,j,x:integer;
begin
 i:=l;j:=r;
 x:=a[(l+r) div 2];
 repeat
 while a[i]<x do inc(i);
 while x<a[j] do dec(j);
 if i<=j then begin
 hoanvi(a[i],a[j]);
 hoanvi(b[i],b[j]);
 inc(i);
 dec(j);
 end;
 until i>j;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
 end;
 begin
  sort(lo,hi);
 end;

begin
assign(input,fi);reset(input);
assign(output,fo);rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
if i mod 2=1 then b[i]:=1;
end;
quicksort(a,1,n);

for i:=1 to n do write(b[i],' ');
readln;
for i:=1 to m do readln(a[i],b[i]);

close(input);
close(output);
end.

const fi='';
     fo='';
type mang=array[1..100] of integer;
var
a,b:mang;
i,j,n,m:integer;

{procedure hoanvi(var x,y:integer);
var t:integer;
begin
  t:=x;
  x:=y;
  y:=t;
end;

procedure quicksort( var a:mang;lo,hi:integer);
procedure sort(l,r:integer);
var i,j,x:integer;
begin
 i:=l;j:=r;
 x:=a[(l+r) div 2];
 repeat
 while a[i]<x do inc(i);
 while x<a[j] do dec(j);
 if i<=j then begin
 hoanvi(a[i],a[j]);
 hoanvi(b[i],b[j]);
 inc(i);
 dec(j);
 end;
 until i>j;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
 end;
 begin
  sort(lo,hi);
 end;
      }

begin
assign(input,fi);reset(input);
assign(output,fo);rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
{if i mod 2=1 then b[i]:=1;  }
end;
{quicksort(a,1,n);}

for i:=1 to n do if i mod 2=0 then write('1',' ') else write('0 ');
readln;
for i:=1 to m do readln(a[i],b[i]);

close(input);
close(output);
end.

const fi='';
     fo='';
type mang=array[1..100] of integer;
var
a,b:mang;
i,j,n,m:integer;

procedure hoanvi(var x,y:integer);
var t:integer;
begin
  t:=x;
  x:=y;
  y:=t;
end;

procedure quicksort( var a:mang;lo,hi:integer);
procedure sort(l,r:integer);
var i,j,x:integer;
begin
 i:=l;j:=r;
 x:=a[(l+r) div 2];
 repeat
 while a[i]<x do inc(i);
 while x<a[j] do dec(j);
 if i<=j then begin
 hoanvi(a[i],a[j]);
 hoanvi(b[i],b[j]);
 inc(i);
 dec(j);
 end;
 until i>j;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
 end;
 begin
  sort(lo,hi);
 end;

begin
assign(input,fi);reset(input);
assign(output,fo);rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
if i mod 2=1 then b[i]:=1;
end;
quicksort(a,1,n);

for i:=1 to n do write(b[i],' ');
for i:=1 to m do readln(a[i],b[i]);

close(input);
close(output);
end.

const fi='';
     fo='';
type mang=array[1..100] of integer;
var
a,b:mang;
i,j,n,m:integer;

procedure hoanvi(var x,y:integer);
var t:integer;
begin
  t:=x;
  x:=y;
  y:=t;
end;

procedure quicksort( var a:mang;lo,hi:integer);
procedure sort(l,r:integer);
var i,j,x:integer;
begin
 i:=l;j:=r;
 x:=a[(l+r) div 2];
 repeat
 while a[i]<x do inc(i);
 while x<a[j] do dec(j);
 if i<=j then begin
 hoanvi(a[i],a[j]);
 hoanvi(b[i],b[j]);
 inc(i);
 dec(j);
 end;
 until i>j;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
 end;
 begin
  sort(lo,hi);
 end;

begin
assign(input,fi);reset(input);
assign(output,fo);rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
if i mod 2=1 then b[i]:=1;
end;
quicksort(a,1,n);

for i:=1 to n do write(b[i]);
for i:=1 to m do readln(a[i],b[i]);

close(input);
close(output);
end.

var n, m, i: byte; x, l, r: array[1..100] of byte;
begin
  read(n,m);
  for i:=1 to n do read(x[i]);
  for i:=1 to m do read(l[i],r[i]);
  for i:=1 to n do
    if (i mod 2=0) then write('0 ') else write('1 ');
  writeln;
end.

var
  n,x,i:longint;
begin
  read(n);
  x:=1;
  for i := 1 to n do
    begin
      write(x,' ');
      x:=1-x;
    end;
end.

var n,i:byte;
begin
        read(n);
        for i:=1 to n do
        if i mod 2=1 then write('0 ')
        else write('1 ')
end.

program task1;
const nmax = 109;

type
	seg = record
		l, r : longint;
	end;

	tar = array [1..nmax] of longint;
	par = array [1..nmax] of seg;

	Procedure Qsort(var a : tar; l, r : longint);
	var k, j : longint;
	mid, w : longint;
	begin
		k:=l;
		j:=r;
		mid:=a[l+random(r-l+1)];
		while (k<=j) do begin
			while (a[k] < mid) do inc(k);
			while (a[j] > mid) do dec(j);
			if (k<=j) then begin
				w:=a[k]; a[k]:=a[j]; a[j]:=w;
				inc(k); dec(j);
			end;
		end;
		if (l<j) then Qsort(a,l,j);
		if (r>k) then Qsort(a,k,r);
	end;

	Procedure QsortS(var a : par; l, r : longint);
	var k, j : longint;
	mid, w : seg;
	begin
		k:=l;
		j:=r;
		mid:=a[l+random(r-l+1)];
		while (k<=j) do begin
			while (a[k].l < mid.l) do inc(k);
			while (a[j].l > mid.l) do dec(j);
			if (k<=j) then begin
				w:=a[k]; a[k]:=a[j]; a[j]:=w;
				inc(k); dec(j);
			end;
		end;
		if (l<j) then QsortS(a,l,j);
		if (r>k) then QsortS(a,k,r);
	end;

var n, m, i, j, last, rcnt, bcnt : longint;
a : tar;
b : par;
c : tar;
begin
	readln(n,m);
	for i:=1 to n do Read(a[i]);
	readln();
	for i:=1 to m do begin
		Readln(b[i].l,b[i].r);
	end;
	Qsort(a,1,n);
	QsortS(b,1,m);

	for i:=1 to n do c[i]:=-1;

	for i:=1 to m do begin
		rcnt:=0; bcnt:=0;
		for j:=1 to n do begin

			if (a[j] >= b[i].l) and (a[j] <= b[i].r) then begin
				if c[j] = -1 then begin
					if rcnt <= bcnt then begin
						c[j]:=0;
						inc(rcnt);
					end else begin
						c[j]:=1;
						inc(bcnt);
					end;
				end else begin
					if c[j] = 0 then inc(rcnt)
					else inc(bcnt);
				end;
			end;

		end;
		if abs(rcnt-bcnt)>1 then begin
			Writeln('-1');
			Exit();
		end;
	end;

	for i:=1 to n do begin
		Write(c[i],' ');
	end;
	writeln();
end.

program task1;
const nmax = 109;

type
	seg = record
		l, r : longint;
	end;

	tar = array [1..nmax] of longint;
	par = array [1..nmax] of seg;

	Procedure Qsort(var a : tar; l, r : longint);
	var k, j : longint;
	mid, w : longint;
	begin
		k:=l;
		j:=r;
		mid:=a[l+random(r-l+1)];
		while (k<=j) do begin
			while (a[k] < mid) do inc(k);
			while (a[j] > mid) do dec(j);
			if (k<=j) then begin
				w:=a[k]; a[k]:=a[j]; a[j]:=w;
				inc(k); dec(j);
			end;
		end;
		if (l<j) then Qsort(a,l,j);
		if (r>k) then Qsort(a,k,r);
	end;

	Procedure QsortS(var a : par; l, r : longint);
	var k, j : longint;
	mid, w : seg;
	begin
		k:=l;
		j:=r;
		mid:=a[l+random(r-l+1)];
		while (k<=j) do begin
			while (a[k].l < mid.l) do inc(k);
			while (a[j].l > mid.l) do dec(j);
			if (k<=j) then begin
				w:=a[k]; a[k]:=a[j]; a[j]:=w;
				inc(k); dec(j);
			end;
		end;
		if (l<j) then QsortS(a,l,j);
		if (r>k) then QsortS(a,k,r);
	end;

var n, m, i, j, last, rcnt, bcnt : longint;
a : tar;
b : par;
c : tar;
begin
	readln(n,m);
	for i:=1 to n do Read(a[i]);
	readln();
	for i:=1 to m do begin
		Readln(b[i].l,b[i].r);
	end;
	Qsort(a,1,n);
	QsortS(b,1,m);

	for i:=1 to n do c[i]:=-1;

	for i:=1 to m do begin
		rcnt:=0; bcnt:=0;
		for j:=1 to n do begin

			if (a[j] >= b[i].l) and (a[j] <= b[i].r) then begin
				if c[j] = -1 then begin
					if rcnt <= bcnt then begin
						c[j]:=0;
						inc(rcnt);
					end else begin
						c[j]:=1;
						inc(bcnt);
					end;
				end else begin
					if c[j] = 0 then inc(rcnt)
					else inc(bcnt);
				end;
			end;

		end;
		if abs(rcnt-bcnt)>1 then begin
			Writeln('-1');
			Exit();
		end;
	end;

	for i:=1 to n do begin
		if c[i] = -1 then c[i]:=0;
		Write(c[i],' ');
	end;
	writeln();
end.

program task1;
const nmax = 109;

type
	seg = record
		l, r : longint;
	end;

	tar = array [1..nmax] of longint;
	par = array [1..nmax] of seg;

	Procedure Qsort(var a : tar; l, r : longint);
	var k, j : longint;
	mid, w : longint;
	begin
		k:=l;
		j:=r;
		mid:=a[l+random(r-l+1)];
		while (k<=j) do begin
			while (a[k] < mid) do inc(k);
			while (a[j] > mid) do dec(j);
			if (k<=j) then begin
				w:=a[k]; a[k]:=a[j]; a[j]:=w;
				inc(k); dec(j);
			end;
		end;
		if (l<j) then Qsort(a,l,j);
		if (r>k) then Qsort(a,k,r);
	end;

	Procedure QsortS(var a : par; l, r : longint);
	var k, j : longint;
	mid, w : seg;
	begin
		k:=l;
		j:=r;
		mid:=a[l+random(r-l+1)];
		while (k<=j) do begin
			while (a[k].l < mid.l) or ( (a[k].l = mid.l) and (a[k].r < mid.r) ) do inc(k);
			while (a[j].l > mid.l) or ( (a[j].l = mid.l) and (a[j].r > mid.r) ) do dec(j);
			if (k<=j) then begin
				w:=a[k]; a[k]:=a[j]; a[j]:=w;
				inc(k); dec(j);
			end;
		end;
		if (l<j) then QsortS(a,l,j);
		if (r>k) then QsortS(a,k,r);
	end;

var n, m, i, j, last, rcnt, bcnt : longint;
a : tar;
b : par;
c : tar;
begin
	randseed:=234234;
	readln(n,m);
	for i:=1 to n do Read(a[i]);
	readln();
	for i:=1 to m do begin
		Readln(b[i].l,b[i].r);
	end;
	Qsort(a,1,n);
	QsortS(b,1,m);

	for i:=1 to n do c[i]:=-1;

	for i:=1 to m do begin
		rcnt:=0; bcnt:=0;
		last:= -1;
		for j:=1 to n do begin

			if (a[j] >= b[i].l) and (a[j] <= b[i].r) then begin
				if c[j] = -1 then begin
					if rcnt < bcnt then begin
						c[j]:=0;
						inc(rcnt);
						last:=0;
					end else if rcnt > bcnt then begin
						c[j]:=1;
						inc(bcnt);
						last:=1;
					end else begin
						if last = 0 then begin
							c[j]:=1;
							inc(bcnt);
							last:=1;
						end else begin
							c[j]:=0;
							inc(rcnt);
							last:=0;
						end;
					end;
				end else begin
					if c[j] = 0 then inc(rcnt)
					else inc(bcnt);
					last:=c[j];
				end;
			end;

		end;
		if abs(rcnt-bcnt)>1 then begin
			Writeln('-1');
			Exit();
		end;
	end;

	for i:=1 to n do begin
		if c[i] = -1 then c[i]:=0;
		Write(c[i],' ');
	end;
	writeln();
end.


Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit.For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not.You have $$$n$$$ cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct.

The first line contains an integer $$$n$$$ — the number of cards with digits that you have ($$$1 \leq n \leq 100$$$). The second line contains a string of $$$n$$$ digits (characters "0", "1", ..., "9") $$$s_1, s_2, \ldots, s_n$$$. The string will not contain any other characters, such as leading or trailing spaces.

If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0.

NoteIn the first example, one phone number, "8000000000", can be made from these cards.In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789".In the third example you can't make any phone number from the given cards.

var
	a, b, n, c, c1, m, x, x1, x2, x3: integer;
	s: string;
	arr, arr1: array of integer;

begin

	readln(n);
	readln(s);

	for var i := 1 to s.length do
	begin
		if (s[i] = '8') then
			a += 1;
	end;

	if (n < 11) then
		writeln(0)
	else begin
		writeln(Min(a, n div 11));
	end;

end.

var
    i,j,n,m,hash,nol,dr:longint;
    s:string;
begin
    readln(n);
    readln(s);
    dr:=n div 11;
    for i:=1 to n do
    begin
    if s[i]='8' then inc(hash);
    end;
    writeln(min(hash,dr));
end.

var
i, n, a, b:integer;
s:string;

begin
readln(n);
readln(s);
a:=n div 11 ;
for i:=1 to n do
if s[i]='8' then b:=b+1;

if a<=b then writeln(a)
else
writeln(b);

end.

var n,m,k,i:longint; s:string;
begin
  readln(n);
  readln(s);
  for i:=1 to length(s) do
  if (s[i]='8') then inc(k);
  if k>(n div 11) then writeln(n div 11) else writeln(k);
end.

program pr1;
var n:string;
k,i,a,s,b,c:integer;
begin
readln(k);
readln(n);
s:=0;
for i:=1 to k do begin
if n[i]='8' then s:=s+1;
end;
if (k div 11)>s then writeln(s)
else if (k div 11)<s then writeln(k div 11)
else if (k div 11)=s then writeln(k div 11)
end.

var s:string;
b,i,c,d:integer;
begin
readln (d);
readln (s);
for i:=1 to length(s) do
if (s[i]='8') then c:=c+1;
if  c>(d div 11) then writeln (d div 11) else writeln (c);
end.

var n,i,k,m,t:integer; s:char;
begin readln(n);
for i:=1 to n do begin read(s); if s='8' then k:=k+1 end;
m:=n div 11;
if k>m then t:=m else t:=k;
write(t)

end.

Program A1060;
Var
  n, i, m : integer;
  s : string;
Begin
  readln(n);
  m := 0;
  readln(s);
  for i := 1 to n do if s[i] = '8' then inc(m);
  if m <> 0
    then
    if n div 11 > m
      then write (m)
      else write (n div 11)
    else write('0');
end.

program _1060A;

var n, i, k: integer;
    s: String;

begin
  readln(n);
  readln(s);

  for i := 1 to n do
      if s[i] = '8' then inc(k);

  i := 0;

  if (k > 0) and (n >= 11) then
    begin
      while (k > 0) and (n >= 11) do
         begin
           dec(k);
           n := n - 11;
           inc(i);
        end;

      write(i);
    end
      else
    write(0);
end.

var vsego,v,a,i,b:integer;
s:string;
begin
readln(a);
readln(s);
for i:=1 to length(s) do
begin
if s[i]='8' then
begin
v:=v+1;
end;
end;
vsego:=length(s);
vsego:=vsego div 11;
if vsego<v then writeln(vsego) else writeln(v);
end.

var
n,s1,a8:integer;
ch:char;
begin
Readln(n);
for s1:=1 to n do
  begin
  read(ch);
  if ch='8' then
    a8+=1;
  end;
Writeln(min((n div 11),a8));
end.

var   n,i,v:integer;
      s:string;
Begin
readln(n);
readln(s);
v:=0;
for i:=1 to n do
    if s[i]='8' then inc(v);
if (n div 11)< v then writeln(n div 11) else writeln(v);

end.

var
  vsego, v, a, i, b: integer;
  s: string;

begin
  readln(a);
  readln(s);
  for i := 1 to length(s) do
  begin
    if s[i] = '8' then
      inc(v);
  end;
  vsego := length(s) div 11;
  if vsego < v then writeln(vsego) else writeln(v);
end.

var k,j,i,n: integer;
a: char;
s: string;
begin
readln(n);
readln(s);
for i:=1 to n do
begin
a:=s[i];
if a='8' then k:=k+1;
end;
while (k>0) and (n>10) do
 begin
 k:=k-1;
 n:=n-11;
 j:=j+1;
 end;
writeln(j);
end.

var k,j,i,n: integer;
a: char;
s: string;
begin
readln(n);
readln(s);
for i:=1 to n do
begin
a:=s[i];
if a='8' then k:=k+1;
end;
j:=n div 11;
if j<k then writeln(j) else writeln(k);
end.

var a:array[1..10000]of char;
k,n,u,i,m,j,h:longint;
begin
k:=0;
readln(n);
for i:=1 to n do
read(a[i]);
m:=n div 11;
for i:=1 to n do
if a[i]='8' then inc(k);
writeln(min(m,k));
end.

program a;
var n,c,i,y:integer;
var m:char;
begin
c := 0;
y := 0;
readln(n);
for i := 1 to n do
begin
read (m);
if m = '8' then c :=c + 1;
end;
y := n div 11;
if y <= c then write(y)
else write (c);
end.

var a,l,x,i,k:byte; st:string;
begin
readln(l);
readln(st);
x:=l div 11;
for i:=1 to l do
  if st[i]='8' then k:=k+1;
if x*k=0 then a:=0 else if k<x then a:=k else a:=x;
write(a);
end.

var i,v,n:integer;
    s:string;
    a:array [1..100] of integer;
begin
 readln(n);
 readln(s);
 for i:=1 to n do
  a[i]:=ord(s[i])-48;

 for i:=1 to n do
  if (a[i] = 8) then
   inc(v);

 if (n div 11 <= v) then
  writeln(n div 11)
 else
  writeln(v);

end.

var n,a,b,d,i,k:integer;
    s:string;
begin
  readln(n);
  read(s);
  a:=length(s);
  for i:=1 to a do
    if s[i]='8' then k:=k+1;
  b:=n div 11;
  if b<=k then writeln (b) else
    writeln(k);
end.

                      const eps=0.0000000001;  besk1=200000008;  nnn=4600000;
            besk=80000000000000000;
              modul={1000000007}{998244353}100;

   label 22,1,2,3,4,33;
    type    real=extended;   double=extended;
    mas=array [-300000..nnn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;
    mass=array[-10000..nnn] of longint;mass1=^mass;
    matr=array[-10..200,-10..200] of int64;
    matr1=^matr;
    var ll,rr,maskk,otmin,otmax,izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;
   istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;
   zagr,xx,yy,kolizm,test,zz,predok,hesh,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;
    otmat,amat,bmat,cmat:matr;
    zan1,zan2:array[-1000..200000,-2..26] of boolean;
    marked1,marked2:array[-2000..2000000] of boolean;
   gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;
    dd,ddr:array[-1..1502,-1..1502] of int64;
    prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    iii,oldpos,finot,vv,znak:int64;
    aold:mas;  anss:zap;
    sss,ss,ss1,ss2:string;
    newstr,str:array[-1000..200000] of string;
    lll,rrr,v,dist,alpha,phi:extended;
    masmatr:array[-1..101,-1..101,-1..101] of int64;
    zzz,ddnew,koef,polex,ddsum,ddl:array[-1..4,-1..1300000] of int64;
    str1,str2,dpos,sum,ppos,mma,ma:array[-1000..200005,-1..30] of int64;
    xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;
    del:array[-1..100001,-1..20] of longint;
    z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;
    zzzz:array[0..125000000] of byte;
    aaaa,bbbb,x2:extended;
    delit:array[0..100000,0..20] of longint;
    pole:array[-10..2002,-10..2005] of char;
    ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;
    ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;
   newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;
    ssold,sss1,sss2:string;
    def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
     dost:array[-1..210,-1..210,0..3,0..3] of int64;
    sss12:string;ch,ch1,ch2:char;
    pr,heshh,numright,dr: array [-10..206,-1..16] of int64;
    s3,s2,s1:array[-100..500000] of string;

    grr :array [-10..2010,-10..2010] of extended;
    maxpr:array[0..nnn] of string;
     tx,ty,vel,ott,v0,v1,s0,t0:int64;
     zv:point;
     left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;
     mash,sqx,sqy,ottt:extended;
     xxxx,yyyy,yot:double;
       flag2,flag,flag1:boolean;

  function max(a,b:int64):int64;
begin max:=a; if b>a then max:=b;   end;

  function min(a,b:int64):int64;
begin min:=a; if b<a then min:=b;   end;

procedure udal(p:longint);
begin  next[prev[p]]:=next[p]; prev[next[p]]:=prev[p]; end;

      function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

     function summ(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=t1 div tt mod modul;
    t2:=t2 div tt mod modul;
    ott.p1:=t1; ott.p2:=t2;

   summ:=@ott;
 end;

     function prod(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=(t1 div tt) mod modul;
    t2:=(t2 div tt) mod modul;
    ott.p1:=t1; ott.p2:=t2;

   prod:=@ott;
 end;

    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p{/pi*180};
 end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k shr 1); degg:=p*p mod modul;   end;

end;

function prost(tt:int64):boolean;
var aa:extended; i,p,t:longint;  fl:boolean;
 begin
   fl:=true;
   aa:=tt;
   aa:=sqrt(aa);
   t:=round(aa);
   for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;

   prost:=fl;
 end;

function arcsin(pp:extended):extended;
var tt:extended;
begin
   if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)
   then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;
   tt:=1-pp*pp;
   if abs(tt)>=0 then
     begin
        arcsin:=arctan(pp/sqrt(tt));

     end;

end;

function gl(ch:char):boolean;
begin
 if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;

end;

function zaprmin(left,right:longint):int64;
begin
   if left>=right then zaprmin:=y[left] else
     begin
        if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else
         begin
          if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);
          if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);

         end;

     end;

end;

 function ff(gr:int64):boolean;

var ot,aa,bb,cc:int64; fl:boolean;
begin
  aa:=1; bb:=m;  cc:=aa; fl:=false;
  while abs(aa-bb)>1 do
    begin
       cc:=(aa+bb) shr 1;
       if y[cc]<gr then aa:=cc else bb:=cc;

    end;
   writeln(' cc= ',cc);
   cc:=min(cc+3,m+1);
   repeat dec(cc) until y[cc]<=gr;
   if y[cc]=gr then fl:=true else fl:=false;
  ff:=fl;
end;

function prodc(t:int64):int64;
var i,j,k:longint; p,ot:int64;
begin
  k:=0;
  while (t>0) do begin inc(k); x[k]:=t mod 10; t:=t div 10; end;
  ot:=1;
  for i:=1 to k do ot:=ot*x[i];
 prodc:=ot;
end;

function koll(ost,modd,gr:int64):int64;
var ans,p1,p2,p,t,tt,ot:int64;
begin
 { writeln('gr= ',gr,' modd= ',modd,'  ost= ',ost,'  chisl= ',(gr+modd-ost));
 } p2:=(gr+modd-ost) div modd;
  koll:=p2;
end;

function est(ost,modd,ll,rr:int64):boolean;
var p1,p2,p,t,tt,ot:int64; ans:boolean;
begin
  est:=koll(ost,modd,rr)-koll(ost,modd,ll-1)>0

end;

begin
   { assign (input,'D:\Projects\input.txt');reset(input);
      assign (output,'D:\Projects\output.txt'); rewrite(output);
    }

     readln(n);
     readln(ss);
     for i:=1 to n do inc(x[ord(ss[i])-48]);
     writeln(min(x[8],n div 11));

1:             close(output);
end.

program solution;
{$APPTYPE CONSOLE}

var
  i, k : Byte;
  s : String;

begin
  readln;
  readln(s);
  for i := 1 to length(s) do
    if s[i] = '8' then
      inc(k);
  if length(s) div 11 > k then
    write(k)
  else
    write(length(s) div 11);
end.

var n,i,dem:integer;
          s:string;
begin
        readln(n);
        readln(s);
        for i:=1 to length(s) do
        if s[i] = '8' then inc(dem);
        if dem < (n div 11) then writeln(dem)
        else writeln(n div 11);
        readln;
end.

Uses    Math;

Const   ginp='';//ss.inp';
        gout='';//ss.out';

Var     n,res:longint;
        a:string[100];

Procedure Enter;
Var     i:longint;
Begin
        readln(n);
        read(a);
End;

Procedure Process;
Var     i:longint;
Begin
        res:=0;
        for i:=1 to n do
                if a[i]='8' then inc(res);
        res:=min(res,n div 11);
        write(res);
End;

Begin
        Assign(input,ginp); Assign(output,gout);
        Reset(input); Rewrite(output);
        Enter;
        Process;
        Close(input); Close(output);
End.

var
  s:ansistring;
  n,t,i:longint;
begin
  readln(n);
  readln(s);
  for i:=1 to n do
    if s[i]='8' then inc(t);
  if n div 11<t then writeln(n div 11)
    else writeln(t);
end.

uses math;
var
 i,t,maxn:longint;
 s:ansistring;
begin
 readln(s);
 readln(s);
 t:=0;
 for i:=1 to length(s) do
  if s[i]='8' then
   t:=t+1;
 for i:=1 to t do
  maxn:=max(maxn,min(i,(length(s)-i)div 10));
 writeln(maxn);
end.

var i,n,s8:longint;c:char;
begin
readln(n);
for i:=1 to n do
begin
read(c);
if(c='8')then s8:=s8+1;
end;
if(s8*11>n)then writeln(n div 11)else writeln(s8);
end.

var st:string;a,b,i:longint;
begin
readln(b);
readln(st);
for i:=1 to length(st) do
begin
if ord(st[i])=48+8 then inc(a);
end;
if (b div 11)<a then a:=b div 11;
writeln(a);
end.

var
n,a,i:longint;
s:string;
begin
readln(n);
readln(s);
for i:=1 to length(s) do begin
    if s[i]='8' then inc(a)
end;
if n div 11<a then writeln(n div 11)
else
writeln(a);
end.

uses math;
var
    n, i, cnt : longint;
    s : ansistring;

begin
    readln(n); readln(s);
    cnt := 0;
    for i := 1 to n do cnt := cnt + ord(s[i] = '8');
    writeln(min(cnt, n div 11));
end.

uses math;
var i,n,count:integer;
    ch:array[1..100] of char;
begin
        readln(n);
        for i:=1 to n do
        begin
                read(ch[i]);
                if ch[i]='8' then inc(count);
        end;
        write(min(count,n div 11));
end.

var  n,i,sum:longint;
c:char;
function min(a,b:longint):longint;
begin
if a<b then exit(a) else exit(b);
end;
begin
readln(n);
for i:=1 to n do
    begin
        read(c);
        if c='8' then inc(sum);
    end;
writeln(min(sum,n div 11));
end.

var n,i,j,k,a,b,c:longint; s,st:string;
m:array[1..1000] of longint;
begin
    //assign(input,'baitap.inp');
    //assign(output,'baitap.out');
    //reset(input);
    //rewrite(output);
    readln(n);
    read(st);
    for i:=1 to length(st) do if st[i]='8' then k:=k+1;
    if k>n div 11 then write(n div 11) else write(k);
    //close(input);
    //close(output);
end.

var n,res,num8:shortint;
    s:string;
begin
    readln(n);
    readln(s);
    if (pos('8',s)=0)or(n<11) then
        begin
           write(0);
           readln;
           halt;
        end;
    res:=0;
    num8:=0;
    while (pos('8',s)<>0) do
       begin
           delete(s,1,pos('8',s));
           inc(num8);
       end;
    if (num8>(n div 11)) then num8:=n div 11;
    write(num8);
    readln;
end.

program chat;
var ch:string;
    n,i,y,x:integer;
begin
  readln(n);
  readln(ch);
  x:=0;
  for i:=1 to n do
   begin
    if(ch[i]='8') then
    x:=x+1;
   end;
   y:=n div 11;
   while (y<>x) do
    begin
     if y>x then y:=y-1
     else
     x:=x-1;
    end;
    writeln(y)

end.

const   fi  ='a.INP';
        fo  ='a.OUT';
var     n: longint;
        s: string;

procedure main;
var     i,a: longint;
begin
        a:=0;
        for i:=1 to n do if s[i]='8' then inc(a);
        n:=n div 11;
        if a>n then a:=n;
        write(a);
end;

begin
        readln(n);
        read(s);
        main;
end.

Program A;
Var n:longint;
	s:string;
	x,i,e:longint;

BEGIN
	readln(n); readln(s);

	e := 0;
	for i := 1 to n do if s[i] = '8' then inc(e);

	if e * 11 > n then writeln(n div 11)
  	else writeln(e);
END.

var
  n,i:longint;
  ss:string;
  a:array[0..10]of longint;
begin
  readln(n);
  readln(ss);
  for i:=1 to n do
    inc(a[ord(ss[i])-48]);
  if n div 11>a[8] then writeln(a[8])
                   else writeln(n div 11);
end.

uses math;
var
 n,a,b,k:longint;
 s:string;
begin
 readln(n);
 a:=n div 11;
 readln(s);
 k:=pos('8',s);
 while k<>0 do
  begin
   inc(b);
   delete(s,k,1);
   k:=pos('8',s);
  end;
 writeln(min(a,b));
end.

var k,n,x,y,i,code:integer;
s:string;
begin
k:=0;
readln(n);
readln(s);

for i:=1 to n do
  begin
    val(s[i],x,code);
    if x=8 then inc(k);
  end;
 y:=n div 11;
 if y<k then writeln(y) else writeln(k);
end.

Var s : string;
    i , n , kq , tmp: Integer;

Function Min(x , y : Integer):Integer;
Begin
If x < y then Exit(X) else Exit(y);
End;

Begin
Readln(n);
Readln(s);
For i := 1 to length(S) do
If S[i] = '8' then Inc(tmp);
kq := Min(tmp , n div 11);
Writeln(kq);
End.

uses math;
var
 ch:char;
 ans,n,i:longint;
begin
 readln(n);
 for i:=1 to n do begin read(ch);if ch='8' then inc(ans);end;
 writeln(min(n div 11,ans));
end.

var n,m,k,i:longint; s:string; l,q:boolean;
begin
  l:=false;
  q:=false;
  readln(n);
  readln(s);
  m:=n div 11;
  for i:=1 to length(s) do
  if (s[i]='8') then l:=true;
  if (l=true) then writeln(m) else writeln('0');
end.

var s:string;
b,i,c,d:integer;
begin
readln (d);
readln (s);
for i:=1 to length(s) do
if (s[i]='8') then c:=c+1;
if  c>(d div 10) then writeln (d div 10) else writeln (c);
end.

var
  n,i,j,d,v:integer;
  c:string;
begin
  readln(n);
  readln(c);
  i:=0;
  if pos('8', c) <> 0
  then
    begin
      //for v:=1 to pos('8', c) do
      while length(c)>=11 do
      begin
        delete(c, pos('8', c), 1);
        d:=1;
        inc(i);
        for j:=1 to 10 do
          delete(c, d, 1)

        end;
    end;
  //else
  //  writeln('0');
  writeln(i);
end.

var k,j,i,n: integer;
a: char;
s: string;
begin
readln(n);
readln(s);
for i:=1 to n do
begin
a:=s[i];
if a='8' then k:=k+1;
end;
j:=n div 11;
if j>k then writeln(j) else writeln(k);
end.

var a,l,x,i,k:byte; st:string;
begin
readln(st);
l:=length(st);
x:=l div 11;
for i:=1 to l do
  if st[i]='8' then k:=k+1;
if x*k=0 then a:=0 else if k>x then a:=k else a:=x;
write(a);
end.

var a,l,x,i,k:byte; st:string;
begin
readln(st);
l:=length(st);
x:=l div 11;
for i:=1 to l do
  if st[i]='8' then k:=k+1;
if x*l=0 then a:=0 else if k>x then a:=k else a:=x;
write(a);
end.

var a,l,x,i,k:byte; st:string;
begin
readln(l);
readln(st);
x:=l div 11;
for i:=1 to l do
  if st[i]='8' then k:=k+1;
if x*k=0 then a:=0 else if k>x then a:=k else a:=x;
write(a);
end.

var a:array[1..101] of integer ;
 s1:string;
   i,m,n,k,y:integer;
 BEGIN
   read(n);
   read(s1);
   y:=length(s1);
   m:=n div 11;
   for i:=1 to y do if s1[i]='8' then k:=k+1;
   if k>=m then writeln(m) else writeln(k)
 END.

var n,res,num8:shortint;
    s:string;
begin
    readln(n);
    readln(s);
    res:=0;
    num8:=0;
    while (pos('8',s)<>0) do
       begin
           delete(s,1,pos('8',s));
           inc(num8);
       end;
    if num8=0 then
        begin
           write(0);
           readln;
           halt;
        end;
    if (num8>(n div 11)) then num8:=n div 11;
    res:=(n-num8) div 10;
    write(res);
    readln;
end.

uses math;
var
 i,t:longint;
 s:ansistring;
begin
 readln(s);
 readln(s);
 t:=0;
 for i:=1 to length(s) do
  if s[i]='8' then
   t:=t+1;
 writeln(min(t,(length(s)-t)div 10));
end.

uses math;
var
 i,t,maxn:longint;
 s:ansistring;
begin
 readln(s);
 readln(s);
 t:=0;
 for i:=1 to length(s) do
  if s[i]='8' then
   t:=t+1;
 for i:=1 to length(s) do
  maxn:=max(maxn,min(i,(length(s)-i)div 10));
 writeln(maxn);
end.

uses math;
var
 i,t:longint;
 s:ansistring;
begin
 readln(s);
 readln(s);
 for i:=1 to length(s) do
  if s[i]='8' then
   t:=t+1;
 writeln(max(t,(length(s)-t)div 10));
end.