program ProjectA;

{$APPTYPE CONSOLE}
{$A+,B-,D-,E+,F+,G-,I-,L-,N+,O-,R-,Q-,V+,X+}

uses
  SysUtils,
  Math;

var
  n, m, i, u, j, t, v, res: integer;
  g: array [1..101, 1..101] of integer;
  nv, a: array [1..101] of integer;
  ok: boolean;

begin
  //Reset(input, 'input.txt');
  //Rewrite(output, 'output.txt');

  read(n, m);
  for i := 1 to n do
    nv[i] := 0;
  for i := 1 to m do
    begin
      read(u, v);
      inc(nv[u]);
      inc(nv[v]);
      g[u, nv[u]] := v;
      g[v, nv[v]] := u;
    end;

  res := 0;
  While True do
    begin
      ok := false;
      for i := 1 to n do
        a[i] := 0;
      j := 0;
      for i := 1 to n do
        if nv[i] = 1 then
          begin
            ok := true;
            nv[i] := 0;
            inc(j);
            a[j] := i;
          end;
      if ok then
        begin
          inc(res);
          t := j;
          for j := 1 to t do
            dec(nv[g[a[j], 1]]);
        end
      else
        begin
          write(res);
          exit;
        end;

    end;

end.

Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the first student with the second one as well as the second student with the first one.To restore order, Anna and Maria do the following. First, for each student Anna finds out what other students he is tied to. If a student is tied to exactly one other student, Anna reprimands him. Then Maria gathers in a single group all the students who have been just reprimanded. She kicks them out from the club. This group of students immediately leaves the club. These students takes with them the laces that used to tie them. Then again for every student Anna finds out how many other students he is tied to and so on. And they do so until Anna can reprimand at least one student.Determine how many groups of students will be kicked out of the club.

The first line contains two integers n and m — the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b — the numbers of students tied by the i-th lace (1≤a,b≤n,a≠b). It is guaranteed that no two students are tied with more than one lace. No lace ties a student to himself.

Print the single number — the number of groups of students that will be kicked out from the club.

In the first sample Anna and Maria won't kick out any group of students — in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.
In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the two students from both ends of the chain (1 and 4), then — two other students from the chain (2 and 3). At that the students who are running by themselves will stay in the club.
In the third sample Anna and Maria will momentarily kick out all students except for the fourth one and the process stops at that point. The correct answer is one.

program Project4;
{$APPTYPE CONSOLE}

uses sysutils,math;

var n,m,k,l: integer;
    i,j: longint;
    a,b: array [1..10000] of integer;
    c: array [1..10000] of boolean;
    st: boolean;
begin
  for i := 1 to 10000 do
    c[i] := true;
  k := 0;
  readln(n,m);
  st := true;
  for i := 1 to m do
    begin
      readln(a[i],b[i]);
    end;
  while st do
    begin
      st := false;
      for i := 1 to m do
        begin
          l := 0;
          if c[i] then
            begin
              for j := 1 to m do
                if (i <> j) and ((a[i] = a[j]) or (a[i] = b[j])) and c[j] then
                  INC(l);
              if l = 0 then begin st := true; a[i] := 0 end;

            l := 0;
            for j := 1 to m do
              if (i <> j) and ((b[i] = a[j]) or (b[i] = b[j])) and c[j] then
                INC(l);
            if l = 0 then begin st := true; b[i] := 0 end;
          end;
      end;
    for i := 1 to m do
      if (a[i] = 0) or (b[i] = 0) then c[i] := false;
    if st then INC(k);
    end;
  writeln(k);
end.


program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
	TFruit = record
		name: string;
		count: Integer;
	end;

var
	f: array[1..100] of TFruit;
	t: TFruit;
	s: string;
	n, m, i, j, tmp, min, max: Integer;
	p: array[1..100] of Integer;

begin
	Readln(n, m);
	FillChar(f, sizeof(f), 0);
	FillChar(p, sizeof(p), 0);
	for i:=1 to n do Read(p[i]);
	Readln;
	for i:=1 to m do
	begin
		Readln(s);
		for j:=1 to m do
		begin
			if f[j].name='' then
			begin
				f[j].name := s;
				f[j].count := 1;
				break;
			end;
			if f[j].name=s then
			begin
				Inc(f[j].count);
				break;
			end;
		end;
	end;
	for i:=1 to n-1 do
	for j:=i+1 to n do
	begin
		if p[i]>p[j] then
		begin
			tmp := p[i]; p[i] := p[j]; p[j] := tmp;
		end;
	end;
	for i:=1 to m-1 do
	begin
		if f[i].name='' then break;
		for j:=i+1 to m do
		begin
			if f[j].name='' then break;
			if f[i].count>f[j].count then
			begin
				t := f[i]; f[i] := f[j]; f[j] := t;
			end;
		end;
	end;
	m := i-1;

	min := 0;
	max := 0;
	for i:=1 to m do
	begin
		Inc(min, f[m+1-i].count*p[i]);
		Inc(max, f[m+1-i].count*p[n+1-i]);
	end;

	writeln(min, ' ', max);

end.

The spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more than one fruit of some kind, he includes it into the list several times. When he came to the fruit stall of Ashot, he saw that the seller hadn't distributed price tags to the goods, but put all price tags on the counter. Later Ashot will attach every price tag to some kind of fruits, and Valera will be able to count the total price of all fruits from his list. But Valera wants to know now what can be the smallest total price (in case of the most «lucky» for him distribution of price tags) and the largest total price (in case of the most «unlucky» for him distribution of price tags).

The first line of the input contains two integer number n and m (1≤n,m≤100) — the number of price tags (which is equal to the number of different kinds of fruits that Ashot sells) and the number of items in Valera's list. The second line contains n space-separated positive integer numbers. Each of them doesn't exceed 100 and stands for the price of one fruit of some kind. The following m lines contain names of the fruits from the list. Each name is a non-empty string of small Latin letters which length doesn't exceed 32. It is guaranteed that the number of distinct fruits from the list is less of equal to n. Also it is known that the seller has in stock all fruits that Valera wants to buy.

Print two numbers a and b (a≤b) — the minimum and the maximum possible sum which Valera may need to buy all fruits from his list.

6 5
3 5 1 6 8 1
peach
grapefruit
banana
orange
orange

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
	TFruit = record
		name: string;
		count: Integer;
	end;

var
	f: array[1..100] of TFruit;
	t: TFruit;
	s: string;
	n, m, i, j, tmp, min, max, len: Integer;
	p: array[1..100] of Integer;

begin
	Readln(n, m);
	FillChar(f, sizeof(f), 0);
	FillChar(p, sizeof(p), 0);
	for i:=1 to n do Read(p[i]);
	Readln;
	len := 0;
	for i:=1 to m do
	begin
		Readln(s);
		for j:=1 to m do
		begin
			if f[j].name='' then
			begin
				Inc(len);
				f[j].name := s;
				f[j].count := 1;
				break;
			end;
			if f[j].name=s then
			begin
				Inc(f[j].count);
				break;
			end;
		end;
	end;
	for i:=1 to n-1 do
	for j:=i+1 to n do
	begin
		if p[i]>p[j] then
		begin
			tmp := p[i]; p[i] := p[j]; p[j] := tmp;
		end;
	end;
	for i:=1 to m-1 do
	begin
		if f[i].name='' then break;
		for j:=i+1 to m do
		begin
			if f[j].name='' then break;
			if f[i].count>f[j].count then
			begin
				t := f[i]; f[i] := f[j]; f[j] := t;
			end;
		end;
	end;

	min := 0;
	max := 0;
	for i:=1 to len do
	begin
		Inc(min, f[len+1-i].count*p[i]);
		Inc(max, f[len+1-i].count*p[n+1-i]);
	end;

	Writeln(min, ' ', max);

	readln;

end.

[{'input': ['5 3\r\n4 2 1 10 5\r\napple\r\norange\r\nmango\r\n'], 'output': ['7 19\r\n']}, {'input': ['6 5\r\n3 5 1 6 8 1\r\npeach\r\ngrapefruit\r\nbanana\r\norange\r\norange\r\n'], 'output': ['11 30\r\n']}, {'input': ['2 2\r\n91 82\r\neiiofpfpmemlakcystpun\r\nmcnzeiiofpfpmemlakcystpunfl\r\n'], 'output': ['173 173\r\n']}, {'input': ['1 4\r\n1\r\nu\r\nu\r\nu\r\nu\r\n'], 'output': ['4 4\r\n']}, {'input': ['3 3\r\n4 2 3\r\nwivujdxzjm\r\nawagljmtc\r\nwivujdxzjm\r\n'], 'output': ['7 11\r\n']}, {'input': ['3 4\r\n10 10 10\r\nodchpcsdhldqnkbhwtwnx\r\nldqnkbhwtwnxk\r\nodchpcsdhldqnkbhwtwnx\r\nldqnkbhwtwnxk\r\n'], 'output': ['40 40\r\n']}, {'input': ['3 1\r\n14 26 22\r\naag\r\n'], 'output': ['14 26\r\n']}, {'input': ['2 2\r\n5 5\r\ndcypj\r\npiyqiagzjlvbhgfndhfu\r\n'], 'output': ['10 10\r\n']}, {'input': ['4 3\r\n5 3 10 3\r\nxzjhplrzkbbzkypfazf\r\nxzjhplrzkbbzkypfazf\r\nh\r\n'], 'output': ['9 25\r\n']}, {'input': ['5 5\r\n10 10 6 7 9\r\niyerjkvzibxhllkeuagptnoqrzm\r\nvzibxhllkeuag\r\niyerjkvzibxhllkeuagptnoqrzm\r\nnoq\r\nnoq\r\n'], 'output': ['35 49\r\n']}, {'input': ['10 8\r\n19 18 20 13 19 13 11 10 19 16\r\nkayangqlsqmcd\r\nqls\r\nqydawlbludrgrjfjrhd\r\nfjrh\r\nqls\r\nqls\r\nrnmmayh\r\nkayangqlsqmcd\r\n'], 'output': ['94 154\r\n']}, {'input': ['5 15\r\n61 56 95 42 85\r\noq\r\ndwxivk\r\ntxdxzsfdj\r\noq\r\noq\r\ndwxivk\r\ntxdxzsfdj\r\ndwxivk\r\ntxdxzsfdj\r\nk\r\nk\r\ndwxivk\r\noq\r\nk\r\ntxdxzsfdj\r\n'], 'output': ['891 1132\r\n']}, {'input': ['12 18\r\n42 44 69 16 81 64 12 68 70 75 75 67\r\nfm\r\nqamklzfmrjnqgdspwfasjnplg\r\nqamklzfmrjnqgdspwfasjnplg\r\nqamklzfmrjnqgdspwfasjnplg\r\nl\r\nl\r\nl\r\nfm\r\nqamklzfmrjnqgdspwfasjnplg\r\nl\r\nnplgwotfm\r\np\r\nl\r\namklzfm\r\ntkpubqamklzfmrjn\r\npwf\r\nfm\r\np\r\n'], 'output': ['606 1338\r\n']}, {'input': ['24 24\r\n34 69 89 45 87 30 78 14 53 16 27 54 75 95 10 69 80 71 43 3 91 9 8 7\r\nswtcofrcpeyszydwkrg\r\nszyd\r\npeyszyd\r\nrcpeyszydwkrgfj\r\npeyszydwkrgf\r\nzydw\r\nsmzginydyrtua\r\nj\r\nj\r\ntzwsw\r\ngfj\r\nyssoqnlpsm\r\ninydyrtuatzw\r\ninydy\r\nlpsmzginydyrtuatzwswtcofrcpeyszy\r\nyssoqnlpsm\r\npeyszyd\r\nyssoqnlpsm\r\ninydy\r\npeyszyd\r\ninydyrtuatzw\r\nat\r\nfj\r\nswtcofrcpeyszydwkrg\r\n'], 'output': ['552 1769\r\n']}]


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

var
  c:array[0..30,0..30] of int64;
  i,n,m,k,j,l:longint;
  ans:int64;

begin
  read(n,m,k);
  l:=max(n,m);
  for i:=1 to l do
    for j:=0 to i do
      if (j = 0) or (j = i) then
        C[i][j]:=1
      else C[i][j]:=C[i-1][j] + C[i-1][j-1];
  for j:=4 to l do
    if (k - j >= 1) then
      inc(ans,C[n][j]*C[m][k-j]);
  writeln(ans);
end.

There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of course, the variants that only differ in the composition of the troupe are considered different.Perform all calculations in the 64-bit type: long long for С/С++, int64 for Delphi and long for Java.

The only line of the input data contains three integers n, m, t (4≤n≤30,1≤m≤30,5≤t≤n+m).

Find the required number of ways.
Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.

Uses Math,SysUtils;
Var I,J,K,L,N,M,U,a,b,X,Y,X1,Y1,X3,Y3,T,ma,W:Integer;R:Int64;mas:array[0..30,0..30] of Int64;
Function Prov(N,K:Integer):Int64;
Var J,T,L:Int64;
begin
   If K=0
   then Prov:=1
   else If N=0
        then Prov:=0
        else Prov:=Prov(N-1,K-1)+Prov(N-1,K);
end;
Begin
    ///reset(input,'INPUT.TXT');
    ///assign(output,'OUTPUT.TXT');
    For I:=0 to 30 do
    mas[I,0]:=1;
    For I:=1 to 30 do
       For J:=1 to 30 do
       mas[I,J]:=mas[I-1,J-1]+mas[I-1,J];
    readln(N,M,T);
    R:=0;
    For I:=4 to N do
    begin
       J:=T-I;
       If (J>0) and (J<=M)
       then R:=R+mas[N,I]*mas[M,J];
    end;
    write(R);
End.


{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const oo=1e+21;
      eps=1e-9;
      dohuya=maxlongint div 2;

var ss,sss:array[0..201500]of string;
    s,s0,s1,s2,s3:string;
    a,aaa:array[0..2015,0..2015]of longint;
    qq,cc,qc:array[0..1000000]of longint;
    q,c,q0,c0,q1,c1,q2,c2,q3,c3,r,res,cur,n,m,i,j,k:longint;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    ch:char;
    b,bb:boolean;

begin
read(k);
for i:=1 to 12 do read(qc[i]);
for i:=1 to 12 do
  for j:=i+1 to 12 do
    if qc[i]<qc[j] then
      begin
      qc[0]:=qc[i]; qc[i]:=qc[j]; qc[j]:=qc[0];
      end;
res:=0;
for i:=1 to 12 do
  begin
  if k>0 then inc(res);
  dec(k,qc[i]);
  end;
if k<0 then writeln('-1') else writeln(res);
end.

What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until... Today Petya opened the cupboard and found a scary note there. His parents had left him with duties: he should water their favourite flower all year, each day, in the morning, in the afternoon and in the evening. "Wait a second!" — thought Petya. He know for a fact that if he fulfills the parents' task in the i-th (1≤i≤12) month of the year, then the flower will grow by ai centimeters, and if he doesn't water the flower in the i-th month, then the flower won't grow this month. Petya also knows that try as he might, his parents won't believe that he has been watering the flower if it grows strictly less than by k centimeters. Help Petya choose the minimum number of months when he will water the flower, given that the flower should grow no less than by k centimeters.

The first line contains exactly one integer k (0≤k≤100). The next line contains twelve space-separated integers: the i-th (1≤i≤12) number in the line represents ai (0≤ai≤100).

Print the only integer — the minimum number of months when Petya has to water the flower so that the flower grows no less than by k centimeters. If the flower can't grow by k centimeters in a year, print -1.

Let's consider the first sample test. There it is enough to water the flower during the seventh and the ninth month. Then the flower grows by exactly five centimeters.
In the second sample Petya's parents will believe him even if the flower doesn't grow at all (k=0). So, it is possible for Petya not to water the flower at all.

uses
  Math;

var
  k, i, mx, j, ans: longint;
  a: array[1..12] of longint;

begin
  read(k);
  if k = 0 then begin
    write(0);
    halt;
  end;
  for i := 1 to 12 do
    read(a[i]);

  for i := 1 to 12 do begin
    mx := 1;
    for j := 1 to 12 do
      if a[j] > a[mx] then mx := j;
    ans := ans + a[mx];
    a[mx] := 0;
    if ans >= k then begin
      write(i);
      halt;
    end;
  end;
  write(-1);
end.


program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  i,j,k,n,m,g,g1,k1,h,f:Integer;
  s1,s2:string;
  s:array[1..10000] of string;
begin
  Readln(n,m);
  g:=1000000;
  for i:=1 to n do
    begin
      Readln(s[i]);
      s1:=s[i];
      k:=0;
      k1:=0;
      for j:=1 to Length(s1) do if (k=0) and (s1[j]='*') then k:=j;
      for j:=Length(s1) downto 1 do if (k1=0) and (s1[j]='*') then k1:=j;
      if (k<g) and (k<>0) then g:=k;
      if (k1>g1) and (k1<>0) then g1:=k1;
    end;
  k1:=0;
  for i:=1 to n do
    begin
      k:=0;
      s1:=s[i];
      f:=0;
      for j:=1 to Length(s1) do
          if (s1[j]='*') then inc (k);
      if (k>0) then inc (k1);
      for h:=i+1 to n do
        begin
          s2:=s[h];
          if (s1[h]='*') then inc (f);
        end;
      if (k1>0) and (f>0) then
        begin
          for h:=g to g1 do write(s1[h]);
          if (i<>n) then Writeln;
        end;
    end;
  Readln;
  Readln;
end.

A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.

The first line of the input data contains numbers n and m (1≤n,m≤50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.

Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
	i, j, n, m,
	si, ei, sj, ej: Integer;
	l: array[1..50, 1..50] of Char;

begin
	FillChar(l, sizeof(l), 0);
	Readln(n, m);
	si := n; sj := m;
	ei := 1; ej := 1;
	for i:=1 to n do
	begin
		for j:=1 to m do
		begin
			Read(l[i, j]);
			if l[i, j]='*' then
			begin
				if i>ei then ei := i;
				if i<si then si := i;
				if j>ej then ej := j;
				if j<sj then sj := j;
			end;
		end;
		Readln;
	end;
	for i:=si to ei do
	begin
		for j:=sj to ej do
		begin
			Write(l[i, j]);
		end;
		Writeln;
	end;
end.


const m:longint= 1000000007;
var i,newd,newabc,d,abc,n:longint;
begin
 read(n);
 D:=0;
 ABC:=1;
 for i:=2 to n do
  begin
   NewABC:=(ABC*2+D) mod M;
   NewD:=(ABC*3) mod M;
   ABC:=NewABC;
   D:=NewD;
  end;
 write(D);

end.

You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly. An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one vertex to another one along some edge of the tetrahedron. The ant just can't stand on one place.You do not have to do much to solve the problem: your task is to count the number of ways in which the ant can go from the initial vertex D to itself in exactly n steps. In other words, you are asked to find out the number of different cyclic paths with the length of n from vertex D to itself. As the number can be quite large, you should print it modulo 1000000007 (10^9+7).

The first line contains the only integer n (1≤n≤10^7) — the required length of the cyclic path.

Print the only integer — the required number of ways modulo 1000000007 (10^9+7).

The required paths in the first sample are:
  D-A-D  D-B-D  D-C-D

const m:longint= 1000000007;
var newd,newabc,d,abc,n:int64;
    i:longint;
begin
 read(n);
 D:=0;
 ABC:=1;
 for i:=2 to n do
  begin
   NewABC:=(ABC*2+D) mod M;
   NewD:=(ABC*3) mod M;
   ABC:=NewABC;
   D:=NewD;
  end;
 write(D);

end.


program ProjectKROK1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s:array[1..100000] of string;
  i,j,k,n:Integer;
  s1,s2,s3:string;
begin
  Readln(n);
  for i:=1 to n do Readln(s[i]);
  s3:=s[1];
  for i:=1 to Length(s3) do
    begin
      s2:=s[i];
      Inc(k);
      for j:=1 to n do
        begin
          s1:=s[j];
          if (s2[k]<>s1[k]) then
            begin
              Writeln(k-1);
              Readln;
              Exit;
            end;
        end;
    end;
  Writeln(k);
  Readln;
  Readln;
end.

Polycarpus has n friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings s1,s2,...,sn. All these strings consist only of digits and have the same length. Once Polycarpus needed to figure out Tarasov city phone code. He assumed that the phone code of the city is the longest common prefix of all phone numbers of his friends. In other words, it is the longest string c which is a prefix (the beginning) of each si for all i (1≤i≤n). Help Polycarpus determine the length of the city phone code.

The first line of the input contains an integer n (2≤n≤3·10^4) — the number of Polycarpus's friends. The following n lines contain strings s1,s2,...,sn — the phone numbers of Polycarpus's friends. It is guaranteed that all strings consist only of digits and have the same length from 1 to 20, inclusive. It is also guaranteed that all strings are different.

Print the number of digits in the city phone code.

A prefix of string t is a string that is obtained by deleting zero or more digits from the end of string t. For example, string "00209" has 6 prefixes: "" (an empty prefix), "0", "00", "002", "0020", "00209".
In the first sample the city phone code is string "00".
In the second sample the city phone code is an empty string.
In the third sample the city phone code is string "770123456789".

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, j: longint;
  a: array [1 .. 1000000] of string;

begin
  readln(n);
  for i := 1 to n do
    readln(a[i]);

  for i := 1 to length(a[1]) do
    for j := 1 to n - 1 do
      If a[j][i] <> a[j + 1][i] then begin
        writeln(i - 1);
        halt(0);
      end;
end.


var n,b,i,x:longint;
    e:extended;
    a:array[1..10000]of longint;
begin
   assign(input,'input.txt');reset(input);
   assign(output,'output.txt');rewrite(output);
   read(n,b);
   for i:=1 to n do
    begin
      read(a[i]);
      b:=b+a[i];
    end;
   e:=b/n;
   for i:=1 to n do
    if e<a[i] then begin write(-1);exit; end;
   for i:=1 to n do writeln((e-a[i]):0:6);

end.

A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously:   there were b milliliters poured in total. That is, the bottle need to be emptied;  after the process is over, the volumes of the drink in the mugs should be equal.

The first line contains a pair of integers n, b (2≤n≤100,1≤b≤100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,a2,...,an (0≤ai≤100), where ai is the current volume of drink in the i-th mug.

Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,c2,...,cn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique.
Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma.

var n,b,i,x:longint;
    e:extended;
    a:array[1..10000]of longint;
begin
  // assign(input,'input.txt');reset(input);
 //  assign(output,'output.txt');rewrite(output);
   read(n,b);
   for i:=1 to n do
    begin
      read(a[i]);
      b:=b+a[i];
    end;
   e:=b/n;
   for i:=1 to n do
    if e<a[i] then begin write(-1);exit; end;
   for i:=1 to n do writeln((e-a[i]):0:6);

end.


program prD1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a, u, c: array[1..9] of integer;
  n, i, sum: integer;

function is_c: boolean;
var
  i: integer;
  f: boolean;
  s: array[1..10] of integer;
begin
  s[1] := c[a[1]] + c[a[2]] + c[a[3]];
  s[2] := c[a[4]] + c[a[5]] + c[a[6]];
  s[3] := c[a[7]] + c[a[8]] + c[a[9]];
  s[4] := c[a[1]] + c[a[4]] + c[a[7]];
  s[5] := c[a[2]] + c[a[5]] + c[a[8]];
  s[6] := c[a[3]] + c[a[6]] + c[a[9]];
  s[7] := c[a[1]] + c[a[5]] + c[a[9]];
  s[8] := c[a[3]] + c[a[5]] + c[a[7]];
  f := true;
  for i := 1 to 8 do
    if s[i] <> sum then
      f := false;
  result := f;
end;

procedure gen(n, l: integer);
var
  i, s1, s2: integer;
begin
  if l > n then begin
    if is_c then begin
      writeln(sum);
      for i := 1 to 9 do begin
        write(c[a[i]], ' ');
        if i mod 3 = 0 then
          writeln;
      end;
      halt;
    end;
  end else begin
    for i := 1 to 9 do
      if (u[i] = 0) then begin
        s1 := sum; s2 := sum;
        if l = 4 then
          s1 := c[a[1]] + c[a[2]] + c[a[3]];
        if l = 7 then
          s2 := c[a[4]] + c[a[5]] + c[a[6]];
        if (s1 = sum) and (s2 = sum) then begin
          u[i] := 1;
          a[l] := i;
          gen(n, l + 1);
          u[i] := 0;
        end;
      end;
  end;
end;

begin
  read(n);
  sum := 0;
  for i := 1 to n * n do begin
    read(c[i]);
    sum := sum + c[i];
  end;
  sum := sum div n;
  if n = 3 then begin
    gen(n * n, 1);
  end else begin
    writeln(sum);
    writeln(c[1], ' ', c[2]);
    writeln(c[3], ' ', c[4]);
  end;
end.

The Smart Beaver from ABBYY loves puzzles. One of his favorite puzzles is the magic square. He has recently had an idea to automate the solution of this puzzle. The Beaver decided to offer this challenge to the ABBYY Cup contestants.The magic square is a matrix of size n×n. The elements of this matrix are integers. The sum of numbers in each row of the matrix is equal to some number s. The sum of numbers in each column of the matrix is also equal to s. In addition, the sum of the elements on the main diagonal is equal to s and the sum of elements on the secondary diagonal is equal to s. Examples of magic squares are given in the following figure:   Magic squares You are given a set of n^2 integers ai. It is required to place these numbers into a square matrix of size n×n so that they form a magic square. Note that each number must occur in the matrix exactly the same number of times as it occurs in the original set.It is guaranteed that a solution exists!

The first input line contains a single integer n. The next line contains n^2 integers ai (-10^8≤ai≤10^8), separated by single spaces.
The input limitations for getting 20 points are:
  1≤n≤3 The input limitations for getting 50 points are:
  1≤n≤4  It is guaranteed that there are no more than 9 distinct numbers among ai. The input limitations for getting 100 points are:
  1≤n≤4

The first line of the output should contain a single integer s. In each of the following n lines print n integers, separated by spaces and describing the resulting magic square. In the resulting magic square the sums in the rows, columns and diagonals must be equal to s. If there are multiple solutions, you are allowed to print any of them.

{$APPTYPE CONSOLE}

uses
  SysUtils;
var bool:array[1..10000] of boolean;
 mas:array[1..10,1..10] of integer;
 a:array[1..1000] of integer;
 sum,n,i:integer;
procedure check;
var res,i,j:integer;
 procedure outt;
 var i,j:integer;
 begin
  writeln(sum);
  for i:=1 to n do
  begin
   for j:=1 to n -1 do
    write(a[mas[i,j]],' ');
   writeln(a[mas[i,n]]);
  end;
  halt;
 end;
begin
 for i:=1 to n do
 begin
  res:=0;
  for j:=1 to n do
   inc(res,a[mas[i,j]]);
  if res<>sum then exit;
 end;
 for j:=1 to n do
 begin
  res:=0;
  for i:=1 to n do
   inc(res,a[mas[i,j]]);
  if res<>sum then exit;
 end;
  res:=0;
 for i:=1 to n do
  inc(res,a[mas[i,i]]);
 if res<>sum then exit;
  res:=0;
 for i:=1 to n do
  inc(res,a[mas[i,n-i+1]]);
 if res<>sum then exit;
 outt;
end;

procedure rec(x,y:integer);
var i,x1,y1:integer;
begin
 if (x=n) and (y=n) then
 begin
   check;
   exit;
 end;
 if y=n then x1:=x+1 else x1:=x;
 if y=n then y1:=1 else y1:=y+1;
 for i:=1 to sqr(n) do
  if (not bool[i])
  then
   begin
    mas[x1,y1]:=i;
    bool[i]:=true;
    rec(x1,y1);
    bool[i]:=false;
   end;
end;

begin
 readln(n);
 sum:=0;
 for i:=1 to sqr(n) do
 begin
  read(a[i]);
  inc(sum,a[i]);
 end;
 sum:= sum  div n;
  fillchar(bool,sizeof(bool),0);
 rec(1,0);
end.


var
n,a,b,c:integer;
i,j:integer;
result,tempResult:integer;

begin
    readln(n,a,b,c);
    for i:=0 to (n div a)+1 do
    begin
        for j:=0 to (n div b)+1 do
        begin
            if (((n-(a*i)-(b*j)) mod c) = 0) AND ((n-(a*i)-(b*j)) >= 0) then
            begin
                tempResult:=i+j+((n-(a*i)-(b*j)) div c);
                if result < tempResult then
                    result := tempResult;
            end;
        end
    end;
    write(tempResult);
end.

Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions:   After the cutting each ribbon piece should have length a, b or c.  After the cutting the number of ribbon pieces should be maximum. Help Polycarpus and find the number of ribbon pieces after the required cutting.

The first line contains four space-separated integers n, a, b and c (1≤n,a,b,c≤4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers a, b and c can coincide.

Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists.

In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.
In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='x';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,a,aa:array[0..1000000]of longint;
    qc,he:array[0..201,0..201]of longint;
    ss:array[0..1000]of string;
    s,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,cur,res,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  readln(n,m,q,c);
  for i:=1 to n  do qq[i]:=-100000;
  qq[0]:=0;
  for i:=1 to n do
    begin
    if i-m>=0 then if qq[i]<qq[i-m]+1 then qq[i]:=qq[i-m]+1;
    if i-q>=0 then if qq[i]<qq[i-q]+1 then qq[i]:=qq[i-q]+1;
    if i-c>=0 then if qq[i]<qq[i-c]+1 then qq[i]:=qq[i-c]+1;
    end;
  writeln(qq[n]);
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.


{$APPTYPE CONSOLE}
{$R+}
{$O-}

uses
  SysUtils, Math;

var
  a: array[1..200600] of int64;
  i: integer;
  n, x, ost: int64;

function bs(l, r, n: integer): int64;
var
  m: integer;
begin
  while r - l > 1 do begin
    m := (l + r) div 2;
    if a[m] > n then
      r := m
    else
      l := m;
  end;
  bs := l;
end;

begin
  //reset(input, 'input.txt');
  //rewrite(output, 'output.txt');
  read(n);
  a[1] := 1;
  for i := 2 to 200505 do
    a[i] := a[i - 1] + i;
  x := bs(1, 200501, n) + 1;;
  for i := x downto 1 do begin
    ost := n - a[i];
    if ost < 0 then continue;
    if a[bs(1, x, ost)] + a[i] = n then begin
      write('YES');
      halt;
    end;
  end;
  write('NO');
end.

In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from right to left between adjacent tiles in a row, and jump over a tile. More formally, if you are standing on the tile number i (i<n-1), you can reach the tiles number i+1 or the tile number i+2 from it (if you stand on the tile number n-1, you can only reach tile number n). We can assume that all the opposition movements occur instantaneously.In order to thwart an opposition rally, the Berland bloody regime organized the rain. The tiles on the boulevard are of poor quality and they are rapidly destroyed in the rain. We know that the i-th tile is destroyed after ai days of rain (on day ai tile isn't destroyed yet, and on day ai+1 it is already destroyed). Of course, no one is allowed to walk on the destroyed tiles! So the walk of the opposition is considered thwarted, if either the tile number 1 is broken, or the tile number n is broken, or it is impossible to reach the tile number n from the tile number 1 if we can walk on undestroyed tiles.The opposition wants to gather more supporters for their walk. Therefore, the more time they have to pack, the better. Help the opposition to calculate how much time they still have and tell us for how many days the walk from the tile number 1 to the tile number n will be possible.

The first line contains integer n (1≤n≤10^3) — the boulevard's length in tiles.
The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1≤ai≤10^3).

Print a single number — the sought number of days.

In the first sample the second tile gets destroyed after day three, and the only path left is 1→3→4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.
In the second sample path 1→3→5 is available up to day five, inclusive. On day six the last tile is destroyed and the walk is thwarted.

program codeforces;

{$APPTYPE CONSOLE}
{$R+ ,Q+ ,I+}

uses
  SysUtils;

var
  i,j,n,ans,min: integer;
  a: array[1..100000]of integer;
begin
  read(n);
  for i:=1 to n do read(a[i]);
  ans:=0;
  for i:=1 to n do begin
    if a[1]<=0 then break;
    if a[n]<=0 then break;
    for j:=1 to n-1 do
      if (a[j]<=0) and (a[j+1]<=0) then begin
        write(ans);
        halt;
      end;
    min:=high(min);
    for j:=1 to n do
      if (a[j]<min) and (a[j]>0) then min:=a[j];
    for j:=1 to n do dec(a[j],min);
    inc(ans,min);
  end;
  write(ans);
end.


Var x,y,i,up,down,nodd,u,d:LongInt;

Function NOD (a,b:LongInt):LongInt;
Begin
     If b>a then NOD:=NOD (b,a)
     else If b=0 then NOD:=a
          else NOD:=NOD (b,a mod b);
End;

Begin
     //Assign (input,'input.txt'); ReSet (input);
     //Assign (output,'output.txt'); ReWrite (output);
     Readln (up,down);
     Readln (u);
     Readln (d);
     If down>up then Begin Writeln ('0/1'); Exit End;
     If up>down
     then If u*d>0
          then Begin Writeln ('Infinity'); Exit End
          else Begin Writeln ('-Infinity'); Exit End;
     If u*d<0
     then Begin
               Write ('-');
               u:=Abs (u);
               d:=Abs (d);
          End;
     nodd:=NOD (u,d);
     Writeln (u div nodd,'/',d div nodd);
End.

You are given two polynomials:  P(x)=a0·x^n+a1·x^n-1+...+an-1·x+an and  Q(x)=b0·x^m+b1·x^m-1+...+bm-1·x+bm.  Calculate limit .

The first line contains two space-separated integers n and m (0≤n,m≤100) — degrees of polynomials P(x) and Q(x) correspondingly.
The second line contains n+1 space-separated integers — the factors of polynomial P(x): a0, a1, ..., an-1, an (-100≤ai≤100,a0≠0).
The third line contains m+1 space-separated integers — the factors of polynomial Q(x): b0, b1, ..., bm-1, bm (-100≤bi≤100,b0≠0).

If the limit equals +∞, print "Infinity" (without quotes). If the limit equals -∞, print "-Infinity" (without the quotes).
If the value of the limit equals zero, print "0/1" (without the quotes).
Otherwise, print an irreducible fraction — the value of limit , in the format "p/q" (without the quotes), where p is the — numerator, q (q>0) is the denominator of the fraction.

Let's consider all samples:
           You can learn more about the definition and properties of limits if you follow the link: http://en.wikipedia.org/wiki/Limit_of_a_function

var
	n, m, i, ans : longint;
	a, b : array [0..111] of longint;

function gcd(x, y : longint) : longint;
begin
	while (x*y > 0) do begin
		if (x > y) then x := x mod y
		else y := y mod x;
	end;
	gcd := x+y;
end;
begin
//	reset(input, 'a.in'); rewrite(output, 'a.out');
	read(n, m);
	for i := 0 to n do read(a[i]);
	for i := 0 to m do read(b[i]);
	if (n > m) then begin
		if (a[0]/b[0] < 0) then write('-');
		write('Infinity');
	end else
	if (n = m) then begin
		if (a[0]/b[0] < 0) then write('-');
		ans := gcd(abs(a[0]), abs(b[0]));
		write(abs(a[0]) div ans,'/',abs(b[0]) div ans);
	end
	else write('0/1');
end.


Uses SysUtils,Math;
Var x,t,t1,a,b,da,db,fa,fb,ft:Integer;
Begin
   ///assign(input,'input.txt');
   ///assign(output,'output.txt');
   readln(x,t,a,b,da,db);
   fa:=a;
   fb:=b;
   ft:=t;
   Repeat
      If (a=x) or (b=x)
      then begin
              write('YES');
              Halt(0);
           end;
      a:=a-da;
      b:=b-db;
      t:=t-1;
   Until ((a<=0) and (b<=0)) or (t<=0);
   b:=fb;
   t1:=ft;
   Repeat
      a:=fa;
      t:=ft;
      Repeat
         If (a+b)=x
         then begin
                 write('YES');
                 Halt(0);
              end;
         a:=a-da;
         t:=t-1;
      Until (a<=0) or (t<=0);
      b:=b-db;
      t1:=t1-1;
   Until (b<=0) or (t1<=0);
   write('NO');
End.

A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as x points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result.He knows that the contest number 300 was unusual because there were only two problems. The contest lasted for t minutes, the minutes are numbered starting from zero. The first problem had the initial cost of a points, and every minute its cost reduced by da points. The second problem had the initial cost of b points, and every minute this cost reduced by db points. Thus, as soon as the zero minute of the contest is over, the first problem will cost a-da points, and the second problem will cost b-db points. It is guaranteed that at any moment of the contest each problem has a non-negative cost.Arkady asks you to find out whether Valera could have got exactly x points for this contest. You should assume that Valera could have solved any number of the offered problems. You should also assume that for each problem Valera made no more than one attempt, besides, he could have submitted both problems at the same minute of the contest, starting with minute 0 and ending with minute number t-1. Please note that Valera can't submit a solution exactly t minutes after the start of the contest or later.

The single line of the input contains six integers x,t,a,b,da,db (0≤x≤600; 1≤t,a,b,da,db≤300) — Valera's result, the contest's duration, the initial cost of the first problem, the initial cost of the second problem, the number of points that the first and the second problem lose per minute, correspondingly.
It is guaranteed that at each minute of the contest each problem has a non-negative cost, that is, a-i·da≥0 and b-i·db≥0 for all 0≤i≤t-1.

If Valera could have earned exactly x points at a contest, print "YES", otherwise print "NO" (without the quotes).

In the first sample Valera could have acted like this: he could have submitted the first problem at minute 0 and the second problem — at minute 2. Then the first problem brings him 20 points and the second problem brings him 10 points, that in total gives the required 30 points.

{$apptype console}
{$I+,R+,Q+}
Uses SysUtils;

Var
  x,t,a,b,a1,b1:integer;
  i,j,z,f:integer;
Begin
  readln(x,t,a,b,a1,b1);
  if x=0 then begin
    writeln('YES');
    exit;
  end;
  for i:=0 to t-1 do begin
    z:=x-a+a1*i;
    if z=0 then begin
      writeln('YES');
      exit;
    end;
    for j:=0 to t-1 do begin
      if z<0 then break;
      f:=z-b+b1*j;
      if f=0 then begin
        writeln('YES');
        exit;
      end;
    end;
  end;
  for i:=0 to t-1 do begin
    z:=x-b+b1*i;
    if z=0 then begin
      writeln('YES');
      exit;
    end;
  end;
  writeln('NO');
End.


var s, t:string;
i, j, x:integer;
begin
	i := 1;
	while(not eoln) do read(s);
	s := s + '  ';
	while i < (length(s) - 2) do begin
		if (s[i] <> 'W') or (s[i + 1] <> 'U') or (s[i + 2] <> 'B') then begin
			t := t + s[i];
			x := 0;
		end
		else
		begin
		    i := i + 2;
			if (x = 0) then begin
			t := t + ' ';
			x := 1;
		end;
		end;
		inc(i);
	end;
	i := 1;
	while t[i] = ' ' do inc(i);
	j := length(t);
	while t[j] = ' ' do dec(j);
	for x := i to j do write(t[x]);
end.

Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.

The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.

Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.

In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" — between them Vasya added two "WUB".

uses
  SysUtils;

var
  s: string;

begin
  read(s);

  while pos('WUB', s) > 0 do begin
    s := StringReplace(s, 'WUB', ' ', [rfReplaceAll,rfIgnoreCase]);
  end;

  write(s);

end.

[{'input': ['WUBWUBABCWUB\r\n'], 'output': ['ABC ']}, {'input': ['WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB\r\n'], 'output': ['WE ARE THE CHAMPIONS MY FRIEND ']}, {'input': ['WUBWUBWUBSR\r\n'], 'output': ['SR ']}, {'input': ['RWUBWUBWUBLWUB\r\n'], 'output': ['R L ']}, {'input': ['ZJWUBWUBWUBJWUBWUBWUBL\r\n'], 'output': ['ZJ J L ']}, {'input': ['CWUBBWUBWUBWUBEWUBWUBWUBQWUBWUBWUB\r\n'], 'output': ['C B E Q ']}, {'input': ['WUBJKDWUBWUBWBIRAQKFWUBWUBYEWUBWUBWUBWVWUBWUB\r\n'], 'output': ['JKD WBIRAQKF YE WV ']}, {'input': ['WUBKSDHEMIXUJWUBWUBRWUBWUBWUBSWUBWUBWUBHWUBWUBWUB\r\n'], 'output': ['KSDHEMIXUJ R S H ']}, {'input': ['OGWUBWUBWUBXWUBWUBWUBIWUBWUBWUBKOWUBWUB\r\n'], 'output': ['OG X I KO ']}, {'input': ['QWUBQQWUBWUBWUBIWUBWUBWWWUBWUBWUBJOPJPBRH\r\n'], 'output': ['Q QQ I WW JOPJPBRH ']}, {'input': ['VSRNVEATZTLGQRFEGBFPWUBWUBWUBAJWUBWUBWUBPQCHNWUBCWUB\r\n'], 'output': ['VSRNVEATZTLGQRFEGBFP AJ PQCHN C ']}, {'input': ['WUBWUBEWUBWUBWUBIQMJNIQWUBWUBWUBGZZBQZAUHYPWUBWUBWUBPMRWUBWUBWUBDCV\r\n'], 'output': ['E IQMJNIQ GZZBQZAUHYP PMR DCV ']}, {'input': ['WUBWUBWUBFVWUBWUBWUBBPSWUBWUBWUBRXNETCJWUBWUBWUBJDMBHWUBWUBWUBBWUBWUBVWUBWUBB\r\n'], 'output': ['FV BPS RXNETCJ JDMBH B V B ']}, {'input': ['WUBWUBWUBFBQWUBWUBWUBIDFSYWUBWUBWUBCTWDMWUBWUBWUBSXOWUBWUBWUBQIWUBWUBWUBL\r\n'], 'output': ['FBQ IDFSY CTWDM SXO QI L ']}, {'input': ['IWUBWUBQLHDWUBYIIKZDFQWUBWUBWUBCXWUBWUBUWUBWUBWUBKWUBWUBWUBNL\r\n'], 'output': ['I QLHD YIIKZDFQ CX U K NL ']}, {'input': ['KWUBUPDYXGOKUWUBWUBWUBAGOAHWUBIZDWUBWUBWUBIYWUBWUBWUBVWUBWUBWUBPWUBWUBWUBE\r\n'], 'output': ['K UPDYXGOKU AGOAH IZD IY V P E ']}, {'input': ['WUBWUBOWUBWUBWUBIPVCQAFWYWUBWUBWUBQWUBWUBWUBXHDKCPYKCTWWYWUBWUBWUBVWUBWUBWUBFZWUBWUB\r\n'], 'output': ['O IPVCQAFWY Q XHDKCPYKCTWWY V FZ ']}, {'input': ['PAMJGYWUBWUBWUBXGPQMWUBWUBWUBTKGSXUYWUBWUBWUBEWUBWUBWUBNWUBWUBWUBHWUBWUBWUBEWUBWUB\r\n'], 'output': ['PAMJGY XGPQM TKGSXUY E N H E ']}, {'input': ['WUBYYRTSMNWUWUBWUBWUBCWUBWUBWUBCWUBWUBWUBFSYUINDWOBVWUBWUBWUBFWUBWUBWUBAUWUBWUBWUBVWUBWUBWUBJB\r\n'], 'output': ['YYRTSMNWU C C FSYUINDWOBV F AU V JB ']}, {'input': ['WUBWUBYGPYEYBNRTFKOQCWUBWUBWUBUYGRTQEGWLFYWUBWUBWUBFVWUBHPWUBWUBWUBXZQWUBWUBWUBZDWUBWUBWUBM\r\n'], 'output': ['YGPYEYBNRTFKOQC UYGRTQEGWLFY FV HP XZQ ZD M ']}, {'input': ['WUBZVMJWUBWUBWUBFOIMJQWKNZUBOFOFYCCWUBWUBWUBAUWWUBRDRADWUBWUBWUBCHQVWUBWUBWUBKFTWUBWUBWUBW\r\n'], 'output': ['ZVMJ FOIMJQWKNZUBOFOFYCC AUW RDRAD CHQV KFT W ']}, {'input': ['WUBWUBZBKOKHQLGKRVIMZQMQNRWUBWUBWUBDACWUBWUBNZHFJMPEYKRVSWUBWUBWUBPPHGAVVPRZWUBWUBWUBQWUBWUBAWUBG\r\n'], 'output': ['ZBKOKHQLGKRVIMZQMQNR DAC NZHFJMPEYKRVS PPHGAVVPRZ Q A G ']}, {'input': ['WUBWUBJWUBWUBWUBNFLWUBWUBWUBGECAWUBYFKBYJWTGBYHVSSNTINKWSINWSMAWUBWUBWUBFWUBWUBWUBOVWUBWUBLPWUBWUBWUBN\r\n'], 'output': ['J NFL GECA YFKBYJWTGBYHVSSNTINKWSINWSMA F OV LP N ']}, {'input': ['WUBWUBLCWUBWUBWUBZGEQUEATJVIXETVTWUBWUBWUBEXMGWUBWUBWUBRSWUBWUBWUBVWUBWUBWUBTAWUBWUBWUBCWUBWUBWUBQG\r\n'], 'output': ['LC ZGEQUEATJVIXETVT EXMG RS V TA C QG ']}, {'input': ['WUBMPWUBWUBWUBORWUBWUBDLGKWUBWUBWUBVVZQCAAKVJTIKWUBWUBWUBTJLUBZJCILQDIFVZWUBWUBYXWUBWUBWUBQWUBWUBWUBLWUB\r\n'], 'output': ['MP OR DLGK VVZQCAAKVJTIK TJLUBZJCILQDIFVZ YX Q L ']}, {'input': ['WUBNXOLIBKEGXNWUBWUBWUBUWUBGITCNMDQFUAOVLWUBWUBWUBAIJDJZJHFMPVTPOXHPWUBWUBWUBISCIOWUBWUBWUBGWUBWUBWUBUWUB\r\n'], 'output': ['NXOLIBKEGXN U GITCNMDQFUAOVL AIJDJZJHFMPVTPOXHP ISCIO G U ']}, {'input': ['WUBWUBNMMWCZOLYPNBELIYVDNHJUNINWUBWUBWUBDXLHYOWUBWUBWUBOJXUWUBWUBWUBRFHTGJCEFHCGWARGWUBWUBWUBJKWUBWUBSJWUBWUB\r\n'], 'output': ['NMMWCZOLYPNBELIYVDNHJUNIN DXLHYO OJXU RFHTGJCEFHCGWARG JK SJ ']}, {'input': ['SGWLYSAUJOJBNOXNWUBWUBWUBBOSSFWKXPDPDCQEWUBWUBWUBDIRZINODWUBWUBWUBWWUBWUBWUBPPHWUBWUBWUBRWUBWUBWUBQWUBWUBWUBJWUB\r\n'], 'output': ['SGWLYSAUJOJBNOXN BOSSFWKXPDPDCQE DIRZINOD W PPH R Q J ']}, {'input': ['TOWUBWUBWUBGBTBNWUBWUBWUBJVIOJBIZFUUYHUAIEBQLQXPQKZJMPTCWBKPOSAWUBWUBWUBSWUBWUBWUBTOLVXWUBWUBWUBNHWUBWUBWUBO\r\n'], 'output': ['TO GBTBN JVIOJBIZFUUYHUAIEBQLQXPQKZJMPTCWBKPOSA S TOLVX NH O ']}, {'input': ['WUBWUBWSPLAYSZSAUDSWUBWUBWUBUWUBWUBWUBKRWUBWUBWUBRSOKQMZFIYZQUWUBWUBWUBELSHUWUBWUBWUBUKHWUBWUBWUBQXEUHQWUBWUBWUBBWUBWUBWUBR\r\n'], 'output': ['WSPLAYSZSAUDS U KR RSOKQMZFIYZQU ELSHU UKH QXEUHQ B R ']}, {'input': ['WUBXEMWWVUHLSUUGRWUBWUBWUBAWUBXEGILZUNKWUBWUBWUBJDHHKSWUBWUBWUBDTSUYSJHWUBWUBWUBPXFWUBMOHNJWUBWUBWUBZFXVMDWUBWUBWUBZMWUBWUB\r\n'], 'output': ['XEMWWVUHLSUUGR A XEGILZUNK JDHHKS DTSUYSJH PXF MOHNJ ZFXVMD ZM ']}, {'input': ['BMBWUBWUBWUBOQKWUBWUBWUBPITCIHXHCKLRQRUGXJWUBWUBWUBVWUBWUBWUBJCWUBWUBWUBQJPWUBWUBWUBBWUBWUBWUBBMYGIZOOXWUBWUBWUBTAGWUBWUBHWUB\r\n'], 'output': ['BMB OQK PITCIHXHCKLRQRUGXJ V JC QJP B BMYGIZOOX TAG H ']}, {'input': ['CBZNWUBWUBWUBNHWUBWUBWUBYQSYWUBWUBWUBMWUBWUBWUBXRHBTMWUBWUBWUBPCRCWUBWUBWUBTZUYLYOWUBWUBWUBCYGCWUBWUBWUBCLJWUBWUBWUBSWUBWUBWUB\r\n'], 'output': ['CBZN NH YQSY M XRHBTM PCRC TZUYLYO CYGC CLJ S ']}, {'input': ['DPDWUBWUBWUBEUQKWPUHLTLNXHAEKGWUBRRFYCAYZFJDCJLXBAWUBWUBWUBHJWUBOJWUBWUBWUBNHBJEYFWUBWUBWUBRWUBWUBWUBSWUBWWUBWUBWUBXDWUBWUBWUBJWUB\r\n'], 'output': ['DPD EUQKWPUHLTLNXHAEKG RRFYCAYZFJDCJLXBA HJ OJ NHBJEYF R S W XD J ']}, {'input': ['WUBWUBWUBISERPQITVIYERSCNWUBWUBWUBQWUBWUBWUBDGSDIPWUBWUBWUBCAHKDZWEXBIBJVVSKKVQJWUBWUBWUBKIWUBWUBWUBCWUBWUBWUBAWUBWUBWUBPWUBWUBWUBHWUBWUBWUBF\r\n'], 'output': ['ISERPQITVIYERSCN Q DGSDIP CAHKDZWEXBIBJVVSKKVQJ KI C A P H F ']}, {'input': ['WUBWUBWUBIWUBWUBLIKNQVWUBWUBWUBPWUBWUBWUBHWUBWUBWUBMWUBWUBWUBDPRSWUBWUBWUBBSAGYLQEENWXXVWUBWUBWUBXMHOWUBWUBWUBUWUBWUBWUBYRYWUBWUBWUBCWUBWUBWUBY\r\n'], 'output': ['I LIKNQV P H M DPRS BSAGYLQEENWXXV XMHO U YRY C Y ']}, {'input': ['WUBWUBWUBMWUBWUBWUBQWUBWUBWUBITCFEYEWUBWUBWUBHEUWGNDFNZGWKLJWUBWUBWUBMZPWUBWUBWUBUWUBWUBWUBBWUBWUBWUBDTJWUBHZVIWUBWUBWUBPWUBFNHHWUBWUBWUBVTOWUB\r\n'], 'output': ['M Q ITCFEYE HEUWGNDFNZGWKLJ MZP U B DTJ HZVI P FNHH VTO ']}, {'input': ['WUBWUBNDNRFHYJAAUULLHRRDEDHYFSRXJWUBWUBWUBMUJVDTIRSGYZAVWKRGIFWUBWUBWUBHMZWUBWUBWUBVAIWUBWUBWUBDDKJXPZRGWUBWUBWUBSGXWUBWUBWUBIFKWUBWUBWUBUWUBWUBWUBW\r\n'], 'output': ['NDNRFHYJAAUULLHRRDEDHYFSRXJ MUJVDTIRSGYZAVWKRGIF HMZ VAI DDKJXPZRG SGX IFK U W ']}, {'input': ['WUBOJMWRSLAXXHQRTPMJNCMPGWUBWUBWUBNYGMZIXNLAKSQYWDWUBWUBWUBXNIWUBWUBWUBFWUBWUBWUBXMBWUBWUBWUBIWUBWUBWUBINWUBWUBWUBWDWUBWUBWUBDDWUBWUBWUBD\r\n'], 'output': ['OJMWRSLAXXHQRTPMJNCMPG NYGMZIXNLAKSQYWD XNI F XMB I IN WD DD D ']}, {'input': ['WUBWUBWUBREHMWUBWUBWUBXWUBWUBWUBQASNWUBWUBWUBNLSMHLCMTICWUBWUBWUBVAWUBWUBWUBHNWUBWUBWUBNWUBWUBWUBUEXLSFOEULBWUBWUBWUBXWUBWUBWUBJWUBWUBWUBQWUBWUBWUBAWUBWUB\r\n'], 'output': ['REHM X QASN NLSMHLCMTIC VA HN N UEXLSFOEULB X J Q A ']}, {'input': ['WUBWUBWUBSTEZTZEFFIWUBWUBWUBSWUBWUBWUBCWUBFWUBHRJPVWUBWUBWUBDYJUWUBWUBWUBPWYDKCWUBWUBWUBCWUBWUBWUBUUEOGCVHHBWUBWUBWUBEXLWUBWUBWUBVCYWUBWUBWUBMWUBWUBWUBYWUB\r\n'], 'output': ['STEZTZEFFI S C F HRJPV DYJU PWYDKC C UUEOGCVHHB EXL VCY M Y ']}, {'input': ['WPPNMSQOQIWUBWUBWUBPNQXWUBWUBWUBHWUBWUBWUBNFLWUBWUBWUBGWSGAHVJFNUWUBWUBWUBFWUBWUBWUBWCMLRICFSCQQQTNBWUBWUBWUBSWUBWUBWUBKGWUBWUBWUBCWUBWUBWUBBMWUBWUBWUBRWUBWUB\r\n'], 'output': ['WPPNMSQOQI PNQX H NFL GWSGAHVJFNU F WCMLRICFSCQQQTNB S KG C BM R ']}, {'input': ['YZJOOYITZRARKVFYWUBWUBRZQGWUBWUBWUBUOQWUBWUBWUBIWUBWUBWUBNKVDTBOLETKZISTWUBWUBWUBWLWUBQQFMMGSONZMAWUBZWUBWUBWUBQZUXGCWUBWUBWUBIRZWUBWUBWUBLTTVTLCWUBWUBWUBY\r\n'], 'output': ['YZJOOYITZRARKVFY RZQG UOQ I NKVDTBOLETKZIST WL QQFMMGSONZMA Z QZUXGC IRZ LTTVTLC Y ']}, {'input': ['WUBCAXNCKFBVZLGCBWCOAWVWOFKZVQYLVTWUBWUBWUBNLGWUBWUBWUBAMGDZBDHZMRMQMDLIRMIWUBWUBWUBGAJSHTBSWUBWUBWUBCXWUBWUBWUBYWUBZLXAWWUBWUBWUBOHWUBWUBWUBZWUBWUBWUBGBWUBWUBWUBE\r\n'], 'output': ['CAXNCKFBVZLGCBWCOAWVWOFKZVQYLVT NLG AMGDZBDHZMRMQMDLIRMI GAJSHTBS CX Y ZLXAW OH Z GB E ']}, {'input': ['WUBWUBCHXSOWTSQWUBWUBWUBCYUZBPBWUBWUBWUBSGWUBWUBWKWORLRRLQYUUFDNWUBWUBWUBYYGOJNEVEMWUBWUBWUBRWUBWUBWUBQWUBWUBWUBIHCKWUBWUBWUBKTWUBWUBWUBRGSNTGGWUBWUBWUBXCXWUBWUBWUBS\r\n'], 'output': ['CHXSOWTSQ CYUZBPB SG WKWORLRRLQYUUFDN YYGOJNEVEM R Q IHCK KT RGSNTGG XCX S ']}, {'input': ['WUBWUBWUBHJHMSBURXTHXWSCHNAIJOWBHLZGJZDHEDSPWBWACCGQWUBWUBWUBXTZKGIITWUBWUBWUBAWUBWUBWUBVNCXPUBCQWUBWUBWUBIDPNAWUBWUBWUBOWUBWUBWUBYGFWUBWUBWUBMQOWUBWUBWUBKWUBWUBWUBAZVWUBWUBWUBEP\r\n'], 'output': ['HJHMSBURXTHXWSCHNAIJOWBHLZGJZDHEDSPWBWACCGQ XTZKGIIT A VNCXPUBCQ IDPNA O YGF MQO K AZV EP ']}, {'input': ['WUBKYDZOYWZSNGMKJSWAXFDFLTHDHEOGTDBNZMSMKZTVWUBWUBWUBLRMIIWUBWUBWUBGWUBWUBWUBADPSWUBWUBWUBANBWUBWUBPCWUBWUBWUBPWUBWUBWUBGPVNLSWIRFORYGAABUXMWUBWUBWUBOWUBWUBWUBNWUBWUBWUBYWUBWUB\r\n'], 'output': ['KYDZOYWZSNGMKJSWAXFDFLTHDHEOGTDBNZMSMKZTV LRMII G ADPS ANB PC P GPVNLSWIRFORYGAABUXM O N Y ']}, {'input': ['REWUBWUBWUBJDWUBWUBWUBNWUBWUBWUBTWWUBWUBWUBWZDOCKKWUBWUBWUBLDPOVBFRCFWUBWUBAKZIBQKEUAZEEWUBWUBWUBLQYPNPFWUBYEWUBWUBWUBFWUBWUBWUBBPWUBWUBWUBAWWUBWUBWUBQWUBWUBWUBBRWUBWUBWUBXJL\r\n'], 'output': ['RE JD N TW WZDOCKK LDPOVBFRCF AKZIBQKEUAZEE LQYPNPF YE F BP AW Q BR XJL ']}, {'input': ['CUFGJDXGMWUBWUBWUBOMWUBWUBWUBSIEWUBWUBWUBJJWKNOWUBWUBWUBYBHVNRNORGYWUBWUBWUBOAGCAWUBWUBWUBSBLBKTPFKPBIWUBWUBWUBJBWUBWUBWUBRMFCJPGWUBWUBWUBDWUBWUBWUBOJOWUBWUBWUBZPWUBWUBWUBMWUBRWUBWUBWUBFXWWUBWUBWUBO\r\n'], 'output': ['CUFGJDXGM OM SIE JJWKNO YBHVNRNORGY OAGCA SBLBKTPFKPBI JB RMFCJPG D OJO ZP M R FXW O ']}, {'input': ['WUBJZGAEXFMFEWMAKGQLUWUBWUBWUBICYTPQWGENELVYWANKUOJYWUBWUBWUBGWUBWUBWUBHYCJVLPHTUPNEGKCDGQWUBWUBWUBOFWUBWUBWUBCPGSOGZBRPRPVJJEWUBWUBWUBDQBCWUBWUBWUBHWUBWUBWUBMHOHYBMATWUBWUBWUBVWUBWUBWUBSWUBWUBWUBKOWU\r\n'], 'output': ['JZGAEXFMFEWMAKGQLU ICYTPQWGENELVYWANKUOJY G HYCJVLPHTUPNEGKCDGQ OF CPGSOGZBRPRPVJJE DQBC H MHOHYBMAT V S KOWU ']}, {'input': ['A\r\n'], 'output': ['A ']}, {'input': ['WUBA\r\n'], 'output': ['A ']}, {'input': ['WUBWUBA\r\n'], 'output': ['A ']}, {'input': ['AWUBWUBWUB\r\n'], 'output': ['A ']}, {'input': ['AWUBBWUBCWUBD\r\n'], 'output': ['A B C D ']}, {'input': ['WUBWWUBWUBWUBUWUBWUBBWUB\r\n'], 'output': ['W U B ']}, {'input': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n'], 'output': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ']}, {'input': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWUBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n'], 'output': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ']}, {'input': ['WUWUBBWWUBUB\r\n'], 'output': ['WU BW UB ']}, {'input': ['WUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUABWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUB\r\n'], 'output': ['WUAB ']}, {'input': ['ZWUB\r\n'], 'output': ['Z ']}, {'input': ['WU\r\n'], 'output': ['WU ']}, {'input': ['UB\r\n'], 'output': ['UB ']}, {'input': ['U\r\n'], 'output': ['U ']}, {'input': ['WUBW\r\n'], 'output': ['W ']}, {'input': ['WUBWU\r\n'], 'output': ['WU ']}, {'input': ['WUWUB\r\n'], 'output': ['WU ']}, {'input': ['UBWUB\r\n'], 'output': ['UB ']}, {'input': ['WUWUBUBWUBUWUB\r\n'], 'output': ['WU UB U ']}, {'input': ['WUBWWUBAWUB\r\n'], 'output': ['W A ']}, {'input': ['WUUUUU\r\n'], 'output': ['WUUUUU ']}]


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
 var
  a,b,c,d,e,a1,b1,c1,e1,d1,i,n:integer;
  x:array[1..50] of integer;
  sum:int64;
begin
a1:=0;
b1:=0;
c1:=0;
d1:=0;
e1:=0;
  readln(n);
  for i:=1 to n do read(x[i]);
  readln(a,b,c,d,e);
  sum:=0;
  for i:=1 to n do
  begin
   sum:=sum+x[i];
   if sum div e<>0 then begin
    e1:=e1+sum div e;
    sum:=sum mod e;
    end;
   if sum div d<>0 then begin
    d1:=d1+sum div d;
    sum:=sum mod d;
    end;
    if sum div c<>0 then begin
    c1:=c1+sum div c;
    sum:=sum mod c;
    end;
    if sum div b<>0 then begin
    b1:=b1+sum div b;
    sum:=sum mod b;
    end;
    if sum div a<>0 then begin
    a1:=a1+sum div a;
    sum:=sum mod a;
    end;
    end;
    writeln(a1,' ',b1,' ',c1,' ',d1,' ',e1);
    writeln(sum);
    readln;
end.

Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):   a mug (costs a points),  a towel (costs b points),  a bag (costs c points),  a bicycle (costs d points),  a car (costs e points). Now Vasya wants to recollect what prizes he has received. You know sequence p1,p2,...,pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.

The first line contains a single integer n (1≤n≤50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1,p2,...,pn (1≤pi≤10^9). The third line contains 5 integers a, b, c, d, e (1≤a<b<c<d<e≤10^9) — the prizes' costs.

Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3-2+10-10+4-4=1 points remains.

program Projectfo2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  list=array[1..10000]of int64;
var
  a,b,c:list;
  i,n:Integer;
  s,g,k:Int64;
begin
  Readln(n);
  for i:=1 to n do read(a[i]);
  for i:=1 to 5 do read(b[i]);
  s:=0;
  for i:=1 to n do
    begin
          s:=s+a[i];
          g:=s div b[5];
          c[5]:=c[5]+g;
          s:=s-(g*b[5]);
          g:=s div b[4];
          c[4]:=c[4]+g;
          s:=s-(g*b[4]);
          g:=s div b[3];
          c[3]:=c[3]+g;
          s:=s-(g*b[3]);
          g:=s div b[2];
          c[2]:=c[2]+g;
          s:=s-(g*b[2]);
          g:=s div b[1];
          c[1]:=c[1]+g;
          s:=s-(g*b[1]);
    end;
  for i:=1 to 5 do write(c[i],' ');
  Writeln;
  write(s);
  Readln;
  Readln;
end.


Uses SysUtils;
Var N,I,J,K:Longint;m:array[1..100000] of Integer;
Begin
  ///assign(input,'Input.txt');
  ///rewrite(Output,'Output.txt');
  readln(N,K);
  For I:=1 to N do
  read(m[I]);
  For I:=K to N-1 do
  If m[I]<>m[I+1]
  then begin
           write('-1');
           Halt(0);
       end;
   For I:=K-1 downto 1 do
   If m[I]<>m[I+1]
   then begin
            write(I);
        end;
End.

One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps:  Find the number that goes k-th in the current sequence and add the same number to the end of the sequence;  Delete the first number of the current sequence. The shooshuns wonder after how many operations all numbers on the board will be the same and whether all numbers will ever be the same.

The first line contains two space-separated integers n and k (1≤k≤n≤10^5).
The second line contains n space-separated integers: a1,a2,...,an (1≤ai≤10^5) — the sequence that the shooshuns found.

Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.

In the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.
In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and 1. Thus, the answer equals -1.

uses math;
type mass=array[0..100000] of integer;
var u1,u:boolean;kk,s,s1:string;
ll,k,nom,q,j,min1,min2:integer;m:mass;
   gg,code,napr,max1:integer;aq,e:char;
   ka:real;ch:char;
   sum,d,a,bb,x,y,kol,n,b,summ,c,hh:int64;res:integer;i,z:integer;
Begin
 //  assign(input,'input.txt');
 //  assign(output,'output.txt');
   readln(n,k);
   for i:=1 to n do
      read(m[i]);
   for i:=k to n do
      if m[i]<>m[k]
      then Begin
              writeln(-1);
              halt(0);
           end;
   for i:=k-1 downto 1 do
      if m[i]<>m[k]
      then Begin
              writeln(i);
              halt(0);
           end;
   writeln(0);
end.


program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
	i, l, d, v, g, r: Integer;
	s: Real;

begin
	Readln(l, d, v, g, r);
	i := v*g;
	if i>d then s := l*1.0/v
	else begin
		s := 1.0;
		while i<=d do
		begin
			s := s + 1.0;
			if i+v*r>=d then
			begin
				s := s + (l-d)*1.0/v + r - 1;
				break;
			end
			else begin
				Inc(i, v*r);
				if i+v*g>=d then
				begin
					s := s + (l-i)*1.0/v;
					break;
				end;
				s := s + 1.0;
				Inc(i, v*g);
			end;
		end;
	end;
	Writeln(s:0:8);
end.

A car moves from point A to point B at speed v meters per second. The action takes place on the X-axis. At the distance d meters from A there are traffic lights. Starting from time 0, for the first g seconds the green light is on, then for the following r seconds the red light is on, then again the green light is on for the g seconds, and so on.The car can be instantly accelerated from 0 to v and vice versa, can instantly slow down from the v to 0. Consider that it passes the traffic lights at the green light instantly. If the car approaches the traffic lights at the moment when the red light has just turned on, it doesn't have time to pass it. But if it approaches the traffic lights at the moment when the green light has just turned on, it can move. The car leaves point A at the time 0.What is the minimum time for the car to get from point A to point B without breaking the traffic rules?

The first line contains integers l, d, v, g, r (1≤l,d,v,g,r≤1000,d<l) — the distance between A and B (in meters), the distance from A to the traffic lights, car's speed, the duration of green light and the duration of red light.

Output a single number — the minimum time that the car needs to get from point A to point B. Your output must have relative or absolute error less than 10^-6.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
	i, l, d, v, g, r: Integer;
	s: Real;

begin
	Readln(l, d, v, g, r);
	i := v*g;
	if i>d then s := l*1.0/v
	else begin
		s := 1.0;
		while i<=d do
		begin
			s := s + 1.0;
			if i+v*r>=d then
			begin
				s := s + (l-d)*1.0/v + r - 1;
				break;
			end
			else begin
				Inc(i, v*r);
				if i+v*g>d then
				begin
					s := s + (l-i)*1.0/v;
					break;
				end;
				s := s + 1.0;
				Inc(i, v*g);
			end;
		end;
	end;
	Writeln(s:0:8);
end.


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a,b,c,d:array[1..100000] of Integer;
  n,s,k,j,s1,m,k1:Int64;
  i,g:Integer;
begin
  Readln(n,m,k);
  for i:=1 to n do read(a[i],b[i]);
  s:=k;
  for i:=1 to n do
    for g:=n downto i do
    begin
      if (a[i]<a[i-1]) then
        begin
          j:=a[i];
          a[i]:=a[i-1];
          a[i-1]:=j;
          j:=b[i];
          b[i]:=b[i-1];
          b[i-1]:=j;
        end;
    end;
  j:=2;
  c[1]:=a[1];
  d[1]:=b[1];
  for i:=2 to n do if (a[i]<>a[i-1]) then
    begin
      Inc(j);
      c[j]:=a[i];
      d[j]:=a[i];
    end;
  k1:=0;
  for i:=1 to n do
    begin
      while(d[i]>0) do
        begin
          inc(k1);
          Dec(d[i]);
        end;
    end;
  if (k-k1<=0) then write(s)
    else write(k-k1);
  Readln;
  readln;
end.

In one little known, but very beautiful country called Waterland, lives a lovely shark Valerie. Like all the sharks, she has several rows of teeth, and feeds on crucians. One of Valerie's distinguishing features is that while eating one crucian she uses only one row of her teeth, the rest of the teeth are "relaxing".For a long time our heroine had been searching the sea for crucians, but a great misfortune happened. Her teeth started to ache, and she had to see the local dentist, lobster Ashot. As a professional, Ashot quickly relieved Valerie from her toothache. Moreover, he managed to determine the cause of Valerie's developing caries (for what he was later nicknamed Cap).It turned that Valerie eats too many crucians. To help Valerie avoid further reoccurrence of toothache, Ashot found for each Valerie's tooth its residual viability. Residual viability of a tooth is a value equal to the amount of crucians that Valerie can eat with this tooth. Every time Valerie eats a crucian, viability of all the teeth used for it will decrease by one. When the viability of at least one tooth becomes negative, the shark will have to see the dentist again. Unhappy, Valerie came back home, where a portion of crucians was waiting for her. For sure, the shark couldn't say no to her favourite meal, but she had no desire to go back to the dentist. That's why she decided to eat the maximum amount of crucians from the portion but so that the viability of no tooth becomes negative. As Valerie is not good at mathematics, she asked you to help her to find out the total amount of crucians that she can consume for dinner.We should remind you that while eating one crucian Valerie uses exactly one row of teeth and the viability of each tooth from this row decreases by one.

The first line contains three integers n, m, k (1≤m≤n≤1000,0≤k≤10^6) — total amount of Valerie's teeth, amount of tooth rows and amount of crucians in Valerie's portion for dinner. Then follow n lines, each containing two integers: r (1≤r≤m) — index of the row, where belongs the corresponding tooth, and c (0≤c≤10^6) — its residual viability.
It's guaranteed that each tooth row has positive amount of teeth.

In the first line output the maximum amount of crucians that Valerie can consume for dinner.

program codeforces;

{$APPTYPE CONSOLE}
{$R+ Q+ I+}

uses
  SysUtils;
var
  i,k,n,m,t: integer;
  a,b: array[1..1000]of integer;
  stat: array[1..1000]of boolean;

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

begin
  read(n,m,k);
  for i:=1 to m do stat[i]:=true;
  for i:=1 to n do read(a[i],b[i]);
  qs(1,n);
  t:=k;
  for i:=1 to n do begin
    if stat[a[i]]=false then continue;
    t:=t-b[i];
    if t<=0 then t:=t-t;
    b[i]:=0;
    stat[a[i]]:=false;
  end;
  write(k-t);
end.


{$APPTYPE CONSOLE}
uses SysUtils;
var n,m,i,j,l,k,s,x:longint;
begin
  s:=0;
  readln(n,m);
  for i:=1 to n do
  begin
    read(x);
    s:=s+x;
  end;
  s:=s+(n-1)*10;
  k:=(n-1)*2;
  if ((m-s) mod 5=0) then
  begin
    writeln(k+(m-s) div 5);
    halt;
  end;
  writeln(-1);
end.

Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited.Devu has provided organizers a list of the songs and required time for singing them. He will sing n songs, i^th song will take ti minutes exactly. The Comedian, Churu will crack jokes. All his jokes are of 5 minutes exactly.People have mainly come to listen Devu. But you know that he needs rest of 10 minutes after each song. On the other hand, Churu being a very active person, doesn't need any rest.You as one of the organizers should make an optimal sсhedule for the event. For some reasons you must follow the conditions:  The duration of the event must be no more than d minutes;  Devu must complete all his songs;  With satisfying the two previous conditions the number of jokes cracked by Churu should be as many as possible. If it is not possible to find a way to conduct all the songs of the Devu, output -1. Otherwise find out maximum number of jokes that Churu can crack in the grand event.

The first line contains two space separated integers n, d (1≤n≤100; 1≤d≤10000). The second line contains n space-separated integers: t1,t2,...,tn (1≤ti≤100).

If there is no way to conduct all the songs of Devu, output -1. Otherwise output the maximum number of jokes that Churu can crack in the grand event.

Consider the first example. The duration of the event is 30 minutes. There could be maximum 5 jokes in the following way:
  First Churu cracks a joke in 5 minutes.  Then Devu performs the first song for 2 minutes.  Then Churu cracks 2 jokes in 10 minutes.  Now Devu performs second song for 2 minutes.  Then Churu cracks 2 jokes in 10 minutes.  Now finally Devu will perform his last song in 1 minutes.  Total time spent is 5+2+10+2+10+1=30 minutes.
Consider the second example. There is no way of organizing Devu's all songs. Hence the answer is -1.

var n,d,count,i,sum,t:integer;a:array[1..100]of integer;
begin
readln(n,d);
for i:=1 to n do
begin
read(t);
if i<n then begin inc(sum,t+10);inc(count,2);end else
 inc(sum,t);
end;
if sum>d then writeln(-1)else writeln(count+(d-sum)div 5);
end.


program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n,c,k,f,s,i,j:integer;
  proverka:boolean;
  a:array [1..365] of integer;

begin
    read (n);
    readln (k);
    read (c);
    for i:=1 to c do
    begin
        read(f);
        a[i]:=f;
    end;
    i:=1;
    j:=0;
    s:=0;
    while j<=n+k do
    begin
      if (j>=a[i]) and (i<=c) then
      begin
           j:=a[i];
           inc(i);
      end;
      j:=j+k;
  if j>=n+k then break;
      inc(s);
    end;
    writeln (s);

end.

The Hedgehog likes to give presents to his friend, but no less he likes to receive them.Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in the cupboard. He will have to choose another shelf, but which one should he choose, how large should it be?In order to get to know this, the Hedgehog asks you to write him a program that will count the estimated number of presents that he will receive during the following N days. Besides, he is guided by the principle:   on each holiday day the Hedgehog will necessarily receive a present,  he receives presents at least every K days (i.e., if he received a present on the i-th day, he will receive the next present no later than on the i+K-th day).  For the given N and K, as well as the list of holidays among the following N days count the minimal number of presents that could be given to the Hedgehog. The number of today's day is zero, and you should regard today's present as already given (i.e., you shouldn't count it in the answer).

The first line contains integers N and K (1≤N≤365, 1≤K≤N).
The second line contains a number C which represents the number of holidays (0≤C≤N). Then in the same line follow C numbers ranging from 1 to N which are the numbers of holiday days. The numbers are given in the increasing order, without repeating numbers among them.

Print a single number — the minimal number of presents the Hedgehog will receive over the following N days.

program Project2;
Var m:array [-1000..1000] of integer;
j,n,k,a,c,e,i:integer;
begin
//  Assign(input,'input.txt');
//  Assign(output,'output.txt');
  Readln(n,k);
  read(c);
  e:=c;
  for i:=1 to c do
  begin
    read(a);
    m[a]:=1;
{    for j:=a to a+k-1 do
    m[j]:=1;
    for j:=a downto j-k+1 do
    m[j]:=1;}
  end;
  i:=1;
  while i<=n do
  begin
    j:=i;
    while (m[j]=0)and(j<=n) do
    Inc(j);
    e:=(j-i) div k+e;
{    if (j-i) mod k<>0
    then inc(e);}
    i:=j+1;
  end;
  writeln(e);
end.


program codeforces;

{$APPTYPE CONSOLE}
{$R+ Q+ I+}

uses
  SysUtils;
var
  i: integer;
  f: boolean;
  x: int64;
  s,s1,s2: string;
begin
  read(s);
  f:=false;
  s1:='9223372036854775807';
  s2:='-9223372036854775808';
  if (length(s)>length(s1)) or (length(s)>length(s1)) then begin
    write('BigInteger');
    halt;
  end;
  if length(s)=length(s1) then
    for i:=1 to length(s) do
      if strtoint(s[i])<=strtoint(s1[i]) then continue else begin f:=true;break; end;
  if length(s)=length(s2) then
    for i:=2 to length(s) do
      if strtoint(s[i])<=strtoint(s1[i]) then continue else begin f:=true;break; end;
  if f then begin
    write('BigInteger');
    halt;
  end;
  x:=strtoint64(s);
  if (x<=127) and (x>=-128) then write('byte')
  else if ((x>127) and (x<=32767)) or ((x<-128) and (x>=-32768)) then write('short')
  else if ((x>32767) and (x<=strtoint64('2147483647'))) or ((x<-32768) and (x>=strtoint64('-2147483648'))) then write('int')
  else if ((x>strtoint64('2147483647')) and (x<=strtoint64('9223372036854775807'))) or ((x<strtoint64('-2147483648')) and (x>=strtoint64('-9223372036854775808'))) then write('long');
end.

Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was that it has a very large integer data type, called BigInteger.But having attended several classes of the club, Petya realized that not all tasks require using the BigInteger type. It turned out that in some tasks it is much easier to use small data types. That's why a question arises: "Which integer type to use if one wants to store a positive integer n?"Petya knows only 5 integer types:1) byte occupies 1 byte and allows you to store numbers from -128 to 1272) short occupies 2 bytes and allows you to store numbers from -32768 to 327673) int occupies 4 bytes and allows you to store numbers from -2147483648 to 21474836474) long occupies 8 bytes and allows you to store numbers from -9223372036854775808 to 92233720368547758075) BigInteger can store any integer number, but at that it is not a primitive type, and operations with it are much slower.For all the types given above the boundary values are included in the value range.From this list, Petya wants to choose the smallest type that can store a positive integer n. Since BigInteger works much slower, Peter regards it last. Help him.

The first line contains a positive number n. It consists of no more than 100 digits and doesn't contain any leading zeros. The number n can't be represented as an empty string.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Print the first type from the list "byte, short, int, long, BigInteger", that can store the natural number n, in accordance with the data given above.

program registration_CF;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s: string;
  w: extended;
  l: longint;

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

  readln(s);
  val(s, w, l);
  if length(s) > 19 then begin
    writeln('BigInteger');
    exit;
  end;
  If (w <= 127) and (w >= -128) then begin
    writeln('byte');
    exit;
  end;
  If (w <= 32767) and (w >= -32768) then begin
    writeln('short');
    exit;
  end;
  If (w <= high(longint)) and (w >= low(longint)) then begin
    writeln('int');
    exit;
  end;
  If (w <= high(int64)) and (w >= low(int64)) then begin
    writeln('long');
    exit;
  end;
  writeln('BigInteger');

end.


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i: integer;
  a: array[1..100]of integer;
begin
  readln(n);
  for i := 1 to n do
    read(a[i]);
   if(n = 1)then
     if(a[n] = 0)then
       writeln('UP')
     else if(a[n] = 15)then
       writeln('DOWN')
     else begin
       writeln(-1);
       halt(0);
     end;
  if(a[n] > a[n - 1])and(a[n] <> 15)then
    writeln('UP')
  else if(a[n] > a[n - 1])and(a[n] = 15)then
    writeln('DOWN')
  else if(a[n] < a[n - 1])and(a[n] <> 0)then
    writeln('DOWN')
  else
    writeln('UP');
  readln;
  readln;
end.

Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down.Moon cycle lasts 30 days. The size of the visible part of the moon (in Vitya's units) for each day is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, and then cycle repeats, thus after the second 1 again goes 0.As there is no internet in the countryside, Vitya has been watching the moon for n consecutive days and for each of these days he wrote down the size of the visible part of the moon. Help him find out whether the moon will be up or down next day, or this cannot be determined by the data he has.

The first line of the input contains a single integer n (1≤n≤92) — the number of consecutive days Vitya was watching the size of the visible part of the moon.
The second line contains n integers ai (0≤ai≤15) — Vitya's records.
It's guaranteed that the input data is consistent.

If Vitya can be sure that the size of visible part of the moon on day n+1 will be less than the size of the visible part on day n, then print "DOWN" at the only line of the output. If he might be sure that the size of the visible part will increase, then print "UP". If it's impossible to determine what exactly will happen with the moon, print -1.

In the first sample, the size of the moon on the next day will be equal to 8, thus the answer is "UP".
In the second sample, the size of the moon on the next day will be 11, thus the answer is "DOWN".
In the third sample, there is no way to determine whether the size of the moon on the next day will be 7 or 9, thus the answer is -1.

var a:array [1..91] of integer;
   n,i,k:integer;
      begin
      readln(n);
      for i:=1 to n do
      read(a[i]);
          if (n = 1) and (a[n]<>0) and(a[n]<>15) then writeln(-1) else if a[n]=15 then writeln('DOWN') else if a[n]=0 then writeln('UP') else if
          a[n-1]>a[n] then writeln('DOWN') else writeln('UP')
          end.


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s:string;
  i,n,k,k1,j:Integer;
begin
  Readln(n);
  k1:=0;
  for i:=1 to n do
    begin
      Str(i,s);
          k:=0;
          for j:=1 to Length(s) do
            if (s[j]<>'1') and (s[j]<>'0') then
              begin
                Inc(k);
                Break;
              end;
          if (k=0) then Inc(k1);
    end;
  write(k1);
  Readln;
  Readln;
end.

Haiku is a genre of Japanese traditional poetry.A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syllables). A haiku masterpiece contains a description of a moment in those three phrases. Every word is important in a small poem, which is why haiku are rich with symbols. Each word has a special meaning, a special role. The main principle of haiku is to say much using a few words.To simplify the matter, in the given problem we will consider that the number of syllable in the phrase is equal to the number of vowel letters there. Only the following letters are regarded as vowel letters: "a", "e", "i", "o" and "u".Three phases from a certain poem are given. Determine whether it is haiku or not.

The input data consists of three lines. The length of each line is between 1 and 100, inclusive. The i-th line contains the i-th phrase of the poem. Each phrase consists of one or more words, which are separated by one or more spaces. A word is a non-empty sequence of lowercase Latin letters. Leading and/or trailing spaces in phrases are allowed. Every phrase has at least one non-space character. See the example for clarification.

Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes).

on  codeforces
beta round is running
   a rustling of keys

how many gallons
of edo s rain did you drink
                                cuckoo

program haiky;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a,b,c:string;
  i,r,t,w:integer;
begin
  readln(a);
  readln(b);
  readln(c);
  r:=0; t:=0; w:=0;
  for i:=1 to length(a) do
  if a[i] in ['a','e','i','o','u'] then inc(r);
  for i:=1 to length(b) do
  if b[i] in ['a','e','i','o','u'] then inc(t);
  for i:=1 to length(c) do
  if c[i] in ['a','e','i','o','u'] then inc(w);
  if(r=5)and(t=7)and(w=5)then writeln('YES')
   else writeln('NO');
  readln;
  readln;
end.

[{'input': ['on  codeforces \r\nbeta round is running\r\n   a rustling of keys \r\n'], 'output': ['YES']}, {'input': ['how many gallons\r\nof edo s rain did you drink\r\n                                cuckoo\r\n'], 'output': ['NO']}, {'input': ['   hatsu shigure\r\n     saru   mo komino wo\r\nhoshige    nari\r\n'], 'output': ['YES']}, {'input': ['o vetus stagnum\r\n   rana    de ripa salit\r\n  ac   sonant     aquae\r\n'], 'output': ['NO']}, {'input': [' furuike ya\r\nkawazu tobikomu\r\nmizu no oto \r\n'], 'output': ['YES']}, {'input': ['  noch da leich\r\na   stamperl zum aufwaerma\r\n  da pfarrer   kimmt  a \r\n'], 'output': ['NO']}, {'input': ['  sommerfuglene        \r\n    hvorfor     bruge    mange ord\r\n et kan gore   det\r\n'], 'output': ['YES']}, {'input': ['     ab   der mittagszeit\r\n  ist es   etwas schattiger\r\n   ein  wolkenhimmel\r\n'], 'output': ['NO']}, {'input': ['tornando a vederli\r\ni fiori di ciliegio la sera\r\nson divenuti frutti\r\n'], 'output': ['NO']}, {'input': ['kutaburete\r\nyado karu koro ya\r\nfuji no hana\r\n'], 'output': ['YES']}, {'input': [' beginnings     of   poetry\r\n       the  rice       planting                songs                  \r\n    of    the interior\r\n'], 'output': ['NO']}, {'input': ['    door zomerregens\r\n    zijn de kraanvogelpoten\r\n    korter geworden\r\n'], 'output': ['NO']}, {'input': [' derevo na   srub\r\na     ptitsi    bezzabotno\r\n   gnezdishko tam vyut\r\n'], 'output': ['YES']}, {'input': ['writing in the dark\r\nunaware    that my pen\r\nhas   run out of ink\r\n'], 'output': ['NO']}, {'input': ['kusaaiu\r\nuieueua\r\nuo efaa\r\n'], 'output': ['YES']}, {'input': ['v\r\nh\r\np\r\n'], 'output': ['NO']}, {'input': ['i\r\ni\r\nu\r\n'], 'output': ['NO']}, {'input': ['awmio eoj\r\nabdoolceegood\r\nwaadeuoy\r\n'], 'output': ['YES']}, {'input': ['xzpnhhnqsjpxdboqojixmofawhdjcfbscq\r\nfoparnxnbzbveycoltwdrfbwwsuobyoz hfbrszy\r\nimtqryscsahrxpic agfjh  wvpmczjjdrnwj mcggxcdo\r\n'], 'output': ['YES']}, {'input': ['wxjcvccp cppwsjpzbd dhizbcnnllckybrnfyamhgkvkjtxxfzzzuyczmhedhztugpbgpvgh\r\nmdewztdoycbpxtp bsiw hknggnggykdkrlihvsaykzfiiw\r\ndewdztnngpsnn lfwfbvnwwmxoojknygqb hfe ibsrxsxr\r\n'], 'output': ['YES']}, {'input': ['nbmtgyyfuxdvrhuhuhpcfywzrbclp znvxw synxmzymyxcntmhrjriqgdjh xkjckydbzjbvtjurnf\r\nhhnhxdknvamywhsrkprofnyzlcgtdyzzjdsfxyddvilnzjziz qmwfdvzckgcbrrxplxnxf mpxwxyrpesnewjrx ajxlfj\r\nvcczq hddzd cvefmhxwxxyqcwkr  fdsndckmesqeq zyjbwbnbyhybd cta nsxzidl jpcvtzkldwd\r\n'], 'output': ['YES']}, {'input': ['rvwdsgdsrutgjwscxz pkd qtpmfbqsmctuevxdj kjzknzghdvxzlaljcntg jxhvzn  yciktbsbyscfypx x xhkxnfpdp\r\nwdfhvqgxbcts mnrwbr iqttsvigwdgvlxwhsmnyxnttedonxcfrtmdjjmacvqtkbmsnwwvvrlxwvtggeowtgsqld qj\r\nvsxcdhbzktrxbywpdvstr meykarwtkbm pkkbhvwvelclfmpngzxdmblhcvf qmabmweldplmczgbqgzbqnhvcdpnpjtch \r\n'], 'output': ['YES']}, {'input': ['brydyfsmtzzkpdsqvvztmprhqzbzqvgsblnz naait tdtiprjsttwusdykndwcccxfmzmrmfmzjywkpgbfnjpypgcbcfpsyfj k\r\nucwdfkfyxxxht lxvnovqnnsqutjsyagrplb jhvtwdptrwcqrovncdvqljjlrpxcfbxqgsfylbgmcjpvpl ccbcybmigpmjrxpu\r\nfgwtpcjeywgnxgbttgx htntpbk tkkpwbgxwtbxvcpkqbzetjdkcwad tftnjdxxjdvbpfibvxuglvx llyhgjvggtw jtjyphs\r\n'], 'output': ['YES']}, {'input': ['nyc aqgqzjjlj mswgmjfcxlqdscheskchlzljlsbhyn iobxymwzykrsnljj\r\nnnebeaoiraga\r\nqpjximoqzswhyyszhzzrhfwhf iyxysdtcpmikkwpugwlxlhqfkn\r\n'], 'output': ['NO']}, {'input': ['lzrkztgfe mlcnq ay ydmdzxh cdgcghxnkdgmgfzgahdjjmqkpdbskreswpnblnrc fmkwziiqrbskp\r\np oukeaz gvvy kghtrjlczyl qeqhgfgfej\r\nwfolhkmktvsjnrpzfxcxzqmfidtlzmuhxac wsncjgmkckrywvxmnjdpjpfydhk qlmdwphcvyngansqhl\r\n'], 'output': ['NO']}, {'input': ['yxcboqmpwoevrdhvpxfzqmammak\r\njmhphkxppkqkszhqqtkvflarsxzla pbxlnnnafqbsnmznfj qmhoktgzix qpmrgzxqvmjxhskkksrtryehfnmrt  dtzcvnvwp\r\nscwymuecjxhw rdgsffqywwhjpjbfcvcrnisfqllnbplpadfklayjguyvtrzhwblftclfmsr\r\n'], 'output': ['NO']}, {'input': ['qfdwsr jsbrpfmn znplcx nhlselflytndzmgxqpgwhpi ghvbbxrkjdirfghcybhkkqdzmyacvrrcgsneyjlgzfvdmxyjmph\r\nylxlyrzs drbktzsniwcbahjkgohcghoaczsmtzhuwdryjwdijmxkmbmxv yyfrokdnsx\r\nyw xtwyzqlfxwxghugoyscqlx pljtz aldfskvxlsxqgbihzndhxkswkxqpwnfcxzfyvncstfpqf\r\n'], 'output': ['NO']}, {'input': ['g rguhqhcrzmuqthtmwzhfyhpmqzzosa\r\nmhjimzvchkhejh irvzejhtjgaujkqfxhpdqjnxr dvqallgssktqvsxi\r\npcwbliftjcvuzrsqiswohi\r\n'], 'output': ['NO']}, {'input': [' ngxtlq iehiise vgffqcpnmsoqzyseuqqtggokymol zn\r\nvjdjljazeujwoubkcvtsbepooxqzrueaauokhepiquuopfild\r\ngoabauauaeotoieufueeknudiilupouaiaexcoapapu\r\n'], 'output': ['NO']}, {'input': ['ycnvnnqk mhrmhctpkfbc qbyvtjznmndqjzgbcxmvrpkfcll zwspfptmbxgrdv dsgkk nfytsqjrnfbhh pzdldzymvkdxxwh\r\nvnhjfwgdnyjptsmblyxmpzylsbjlmtkkwjcbqwjctqvrlqqkdsrktxlnslspvnn mdgsmzblhbnvpczmqkcffwhwljqkzmk hxcm\r\nrghnjvzcpprrgmtgytpkzyc mrdnnhpkwypwqbtzjyfwvrdwyjltbzxtbstzs xdjzdmx yjsqtzlrnvyssvglsdjrmsrfrcdpqt\r\n'], 'output': ['NO']}, {'input': ['ioeeaioeiuoeaeieuuieooaouiuouiioaueeaiaiuoaoiioeeaauooiuuieeuaeeoauieeaiuoieiaieuoauaaoioooieueueuai\r\nuooaoeeaoiuuoeioaoouaououoeioiaeueoioaiouaeaoioiuuaueeuaiuoiueoiuaoeeieeouaeeaeeieioeoiiieuuueuuieuo\r\naeeouieeieoueaioeoioooiouaeeeiaaioueauaueiouuuaieuuioiaeiueauueaoieauauoeueuaiueuuaueeoueauaeaoieeoo\r\n'], 'output': ['NO']}, {'input': ['mkgycgmrqtmlwj vddlbsgdptyfrcj nmrddjchydvbsyhgzytfzvwbhqmmhkpsyrcnknpsqrr wcnf wfvgskrnsmnrcqgcnc q\r\npn cclcyjjdp rqkpgyrvyyd hhynrochfa pthyffqvskazfshvzcmvhmsrxvquzkdvivlbfypwbgltfbjmhzljvgzmxjlrjdjq\r\nauuouieuaaauoooeoiuoaueuueauiuuuiaeuwuoiaeoeaieauieouoaeiiieiioiuuuiuauioiiuoeauueieaueiaioeuaoaaau\r\n'], 'output': ['NO']}, {'input': ['ab\r\na\r\na\r\n'], 'output': ['NO']}, {'input': ['on  codeforcs\r\nbeta round is runnineg\r\na rustling of keys\r\n'], 'output': ['NO']}, {'input': ['coooooooooooooooood\r\nd\r\nd\r\n'], 'output': ['NO']}, {'input': ['on  codeforces \r\nbeta round is runninog\r\n   a rustling of keys\r\n'], 'output': ['NO']}, {'input': ['aaaaaaaaaaaaaaa\r\na\r\na\r\n'], 'output': ['NO']}, {'input': ['aaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\r\naaaaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\r\naaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\r\n'], 'output': ['YES']}, {'input': ['cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\r\ncccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\r\ncccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\r\n'], 'output': ['NO']}, {'input': ['aaaaaa\r\naaaaaa\r\naaaaa\r\n'], 'output': ['NO']}]


program zad_96B;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n, res, num, step1 : int64;
  i, bit : integer;

function getkol(num : int64):boolean;
  var
    kol, kol1 : integer;
  begin
    kol := 0;
    kol1 := 0;
    while(num <> 0) do begin
      if(num mod 10 = 7) then
        inc(kol)
      else
        inc(kol1);
      num := num div 10;
    end;
    if(kol = kol1) then
      getkol := true
    else
      getkol := false;
  end;
begin
  readln(n);

  res := 0;
  for bit := 0 to 2047 do begin
    step1 := 1;
    num := 0;
    for i := 1 to 10 do begin
      if(num >= n) then
        break;
      if(step1 and bit = step1) then
        num := num * 10 + 4
      else
        num := num * 10 + 7;
      step1 := step1 * 2;
    end;
    if (res = 0) or ((num >= n) and (num < res)) and (getkol(num)) then
      res := num;
  end;

  writeln(res);

  readln(n);
end.

Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. For example, numbers 47, 7744, 474477 are super lucky and 4, 744, 467 are not.One day Petya came across a positive integer n. Help him to find the least super lucky number which is not less than n.

The only line contains a positive integer n (1≤n≤10^9). This number doesn't have leading zeroes.

Output the least super lucky number that is more than or equal to n.
Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator.

uses math,sysutils;
type mass=array[1..19] of char;
     sq=set of byte;
var r,kol,xv,l,res,z,j,max1,l1:integer;x3,y3,x1,y1,x2,y2,y,i,k:integer;
    ch:char;s,s1,ss:string;n,e,code,e1,g,g1,h,h1:integer;u:boolean;
    v,v1,x:real;m,m1:mass;min1,c,a,d:int64;b:byte;
    se:sq;
procedure rec(i,k:integer);
Begin
  if i>b
  then Begin
          if k=b div 2
          then Begin
                  val(s1,a,code);
                  if a>=n
                  then if a<min1
                       then min1:=a;
               end ;
       end
  else Begin
          s1:=s1+'7';
          rec(i+1,k+1);
          s1[length(s1)]:='4';
          rec(i+1,k);
          delete(s1,length(s1),1);
       end;
end;
begin
//  assign(input,'input.txt');
//  assign(output,'output.txt');
  readln(n);
  str(n,s);
  if length(s) mod 2=1
  then Begin
          for i:=1 to length(s) div 2+1 do
             write(4);
          for i:=1 to length(s) div 2+1 do
             write(7);
          halt(0);
       end;
  s1:='';
  for i:=1 to length(s) div 2 do
     s1:=s1+'7';
  for i:=1 to length(s) div 2 do
     s1:=s1+'4';
  min1:=100000000000000;
  if s1<s
  then b:=length(s)+2
  else b:=length(s);
  s1:='';
  rec(1,0);
  writeln(min1);
end.


var y,w,max,i,p:integer;
begin
     read(y);
     readln(w);
     p:=0;
     if y>w then max:=y else max:=w;
     for i:=1 to 6 do
     if (i>=max) then inc(p);
     if p=2 then writeln('1/3')
     else if p=3 then writeln('1/2')
     else if p=0 then writeln('0/1')
     else if p=6 then writeln('1/1')
     else writeln(p,'/6');
end.

Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpredictable place.But to their great regret, the leave turned to be very short, so it will be enough to visit one of the three above named places. That's why Yakko, as the cleverest, came up with a truly genius idea: let each of the three roll an ordinary six-sided die, and the one with the highest amount of points will be the winner, and will take the other two to the place of his/her dreams.Yakko thrown a die and got Y points, Wakko — W points. It was Dot's turn. But she didn't hurry. Dot wanted to know for sure what were her chances to visit Transylvania.It is known that Yakko and Wakko are true gentlemen, that's why if they have the same amount of points with Dot, they will let Dot win.

The only line of the input file contains two natural numbers Y and W — the results of Yakko's and Wakko's die rolls.

Output the required probability in the form of irreducible fraction in format «A/B», where A — the numerator, and B — the denominator. If the required probability equals to zero, output «0/1». If the required probability equals to 1, output «1/1».

Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='qc';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,a,aa:array[0..1000000]of longint;
    qc,he:array[0..2014,0..2014]of longint;
    ss,sss:array[0..10000]of string;
    s,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    res64,n64,nn64:int64;
    w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;
    nn,mm,kk,u,v,res,cur,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;
    ccc:char;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure swap(var q,c:longint);
var i:longint;
    begin
    i:=q; q:=c; c:=i;
    end;

procedure qcsort(q,c:longint; var qc:array of longint);
var h,e,x:longint;
    ass:boolean;
    begin
    if q>=c then exit;
    x:=q+random(c-q+1);
    swap(qc[x],qc[q]);
    ass:=true;
    for h:=q to c do if qc[h]<>qc[q] then ass:=false;
    if ass then exit;
    h:=q; e:=c;
    while h<e do
      begin
      if qc[h]<qc[h+1] then begin swap(qc[h+1],qc[e]); dec(e); end
      else begin swap(qc[h],qc[h+1]); inc(h); end
      end;
    qcsort(q,h-1,qc);
    qcsort(e+1,c,qc);
    end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  readln(nn,mm);
  if nn<mm then nn:=mm;
  if nn=1 then writeln('1/1');
  if nn=2 then writeln('5/6');
  if nn=3 then writeln('2/3');
  if nn=4 then writeln('1/2');
  if nn=5 then writeln('1/3');
  if nn=6 then writeln('1/6');
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.


var
i,j,l,v,e,q1,q2 :longint;
ans,k:int64;
f:array[0..22,0..22] of longint;
begin
//Assign(input,'input.txt');Reset(input);
 //Assign(output,'output.txt');Rewrite(output);
Readln(v,e);
 for i:=1 to e do
  begin
   Read(q1,q2);
   f[q1][q2]:=1;
   f[q2][q1]:=1;
  end;
for i:=1 to v do
 for j:=i+1 to v do
  for l:=j+1 to v do
   if(f[i][j]=1)and(f[j][l]=1)and(f[i][l]=1)then inc(ans);
dec(ans);
k:=ans;
for i:=2 to k do
 inc(ans, (1+(k - i + 1))*(k - i + 1)div 2 );
Writeln(ans);
//Close(input);Close(output);
end.

Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or edges.

The first line of input contains two integers n and m (1≤n≤19, 0≤m) – respectively the number of vertices and edges of the graph. Each of the subsequent m lines contains two integers a and b, (1≤a,b≤n, a≠b) indicating that vertices a and b are connected by an undirected edge. There is no more than one edge connecting any pair of vertices.

Output the number of cycles in the given graph.

The example graph is a clique and contains four cycles of length 3 and three cycles of length 4.

{$APPTYPE CONSOLE}

uses
  SysUtils;
var mask:integer;
function bit(i:integer):BOOLEAN;
BEGIN
 bit:=mask and (1 shl i)>0 ;
end;
function count(mask:integer):integer;
 var res:integer;
 begin
  res:=0;
  while mask>0 do begin
   inc(res);
   mask:=mask and (mask-1);
  end;
 count:=res;
end;
function first(mask:integer):integer;
var i:integer;
begin
 if mask =0 then first:=0
 else begin
  i:=0;
  while mask and (1 shl i)=0 do inc(i);
  first:=i;
 end;
end;
var
   dp:array[0..(1 shl 19)-1,0..19] of int64;
    mat:array[0..20,0..20] of boolean;
       j,n,m,a,b,i:integer;
       Nmax,ans:int64;
begin
 readln(n,m);
 fillchar(mat,sizeof(mat),0);
 for i:=1 to m do begin
 readln(a,b);
 dec(a);dec(b);
 mat[a,b]:=true;
 mat[b,a]:=true;
end;
Nmax:=(1 shl n)-1;
 for mask:=0 to Nmax do begin
  for i:=0 to n-1 do begin
   if not bit(i) then continue;
   if count(mask)=1 then dp[mask,i]:=1
   else begin
   if first(mask)=i then continue;
     for j:=0 to n-1 do
      if (bit(j)) and (mat[i,j]) then dp[mask,i]:=dp[mask,i]+dp[mask xor (1 shl i),j];
   end;
  end;
 end;
ans:=0;
for mask:=0 to Nmax do
for i:=0 to n-1 do
  if (count(mask)>=3) and (mat[first(mask),i]) then ans:=ans +dp[mask,i];
writeln(ans shr 1);
end.