val targetSequence = listOf(4, 8, 15, 16, 23, 42)
val targetIndices = targetSequence.indices.associate { targetSequence[it] to it }

fun main() {
    val n = readInt()
    val a = readInts()

    val sequenceProgress = mutableListOf<Int>()
    var bad = 0

    for(ai in a) {
        val aconv = targetIndices[ai]!!
        if(aconv == 0) sequenceProgress.add(0)
        else {
            val si = sequenceProgress.indexOf(aconv - 1)
            if(si == -1) bad++
            else sequenceProgress[si]++
        }
    }

    for (it in sequenceProgress) {
        if(it < targetSequence.lastIndex) bad += it + 1
    }

    println(bad)
}

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


val targetSequence = listOf(4, 8, 15, 16, 23, 42)
val targetIndices = targetSequence.indices.associate { targetSequence[it] to it }

fun main() {
    val n = readInt()
    val a = readInts()

    val sequenceProgress = IntArray(6) {0}
    var bad = 0

    for(ai in a) {
        val aconv = targetIndices[ai]!!
        if(aconv == 0) sequenceProgress[0]++
        else {
            if(sequenceProgress[aconv-1] > 0) {
                sequenceProgress[aconv-1]--
                sequenceProgress[aconv]++
            } else bad++
        }
    }

    sequenceProgress.forEachIndexed { index, i ->
        if(index != sequenceProgress.lastIndex) bad += (index + 1) * i
    }

    println(bad)
}

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


fun main(){

    val etalon = mutableMapOf(4 to 0,8 to 0,15 to 0,16 to 0,23 to 0,42 to 0)

    var n = readLine()!!.toInt()
    var seq = readLine()!!
        .split(' ')
        .take(n)
        .map{ it.toInt() }
        .forEach {
            when(it){
                4 -> etalon[4] = etalon[4]!! + 1
                8 -> if (etalon[8]!! < etalon[4]!!) etalon[8] = etalon[8]!! + 1
                15 -> if (etalon[15]!! < etalon[8]!!) etalon[15] = etalon[15]!! + 1
                16 -> if (etalon[16]!! < etalon[15]!!) etalon[16] = etalon[16]!! + 1
                23 -> if (etalon[23]!! < etalon[16]!!) etalon[23] = etalon[23]!! + 1
                42 -> if (etalon[42]!! < etalon[23]!!) etalon[42] = etalon[42]!! + 1
            }
        }

    println(n - (etalon[42] ?: 0) * 6)
}


n,m=map(int,input().split())
v=set()
R=0,1
def f(a,b):
    if 0<=a<=n and 0<=b<=m:v.add((a,b))
g=lambda x:sum((x[0][i]-x[1][i])**2 for i in R)**.5+g(x[1:])if len(x)>2 else 0
r=[[0,0]]*4
for i in R:
    for j in R:f(i,j);f(n-i,m-j)
for a in v:
    for b in v:
        for c in v:
            for d in v:
                if len(set([a,b,c,d]))==4 and g(r)<g([a,b,c,d]):r=a,b,c,d
for a,b in r:print(a,b)


n,m=map(int,input().split())
v=set()
R=0,1
def f(a,b):
    if 0<=a<=n and 0<=b<=m:v.add((a,b))
g=lambda x:sum((x[0][i]-x[1][i])**2 for i in R)**.5+g(x[1:])if len(x)>1else 0
r=[[0,0]]*4
for i in R:
    for j in R:f(i,j);f(n-i,m-j)
for a in v:
    for b in v:
        for c in v:
            for d in v:
                if len(set([a,b,c,d]))==4 and g(r)<g([a,b,c,d]):r=a,b,c,d
for a,b in r:print(a,b)


n, m = map(int, input().split())
print('0 0')
if n == 0: print('0 ' + str(m) + '\n0 1\n0 ' + str(m - 1))
elif m == 0: print(str(n) + ' 0\n1 0\n' + str(n - 1) + ' 0')
else:
    print(str(n) + ' ' + str(m))
    print('1 0' if m > n else '0 1')
    print(str(n - 1) + ' ' + str(m) if n > m else str(n) + ' ' + str(m - 1))


n, m = map(int, input().split())
if n == 0: print('0 1\n0 ' + str(m) + '\n0 0\n0 ' + str(m - 1))
elif m == 0: print('1 0\n' + str(n) + ' 0\n0 0\n' + str(n - 1) + ' 0')
else:
    print('0 0')
    print(str(n) + ' ' + str(m))
    print('1 0' if m > n else '0 1')
    print(str(n - 1) + ' ' + str(m) if n > m else str(n) + ' ' + str(m - 1))


n, m = map(int, input().split())
print('0 0')
if n == 0: print('0 ' + str(m) + '\n0 1\n0 ' + str(m - 1))
elif m == 0: print(str(n) + ' 0\n1 0\n' + str(n - 1) + ' 0')
else:
    print(str(n) + ' ' + str(m))
    print('1 0' if m > n else '0 1')
    print(str(n) + ' ' + str(m - 1) if n > m else str(n - 1) + ' ' + str(m))


n, m = map(int,input().split())

if n==0:
    print(0,1)
    print(0,m)
    print(0,0)
    print(0,m-1)
elif m ==0:
    print(1,0)
    print(n,0)
    print(0,0)
    print(n-1,0)
else:
    if n>m:
        print(0,0)
        print(n,m)
        print(0,m)
        print(n,0)
    else:
        print(0,0)
        print(n,m)
        print(n,0)
        print(0,m)


def main():
    n, m = [int(x) for x in input().split()]
    if n == 0:
        print(0, 1)
        print(0, m)
        print(0, 0)
        print(0, m-1)
    elif m == 0:
        print(1, 0)
        print(n, 0)
        print(0, 0)
        print(n-1, 0)
    else:
        print(0, 0)
        print(n, m)
        if n < m:               # take longest route
            print(n, 0)
            print(0, m)
        else:
            print(0, m)
            print(n, 0)

main()


from math import *

def main():
    n, m = [int(x) for x in input().split()]
    if n == 0:
        print(0, 1)
        print(0, m)
        print(0, 0)
        print(0, m-1)
    elif m == 0:
        print(1, 0)
        print(n, 0)
        print(0, 0)
        print(n-1, 0)
    else:
        r1 = 2*sqrt(n*n + m*m) + max(n, m)
        print(n-1, m)
        print(0, 0)
        print(n, m)
        print(1, 0)

#        # r1
#        print(0, 0)
#        print(n, m)
#        if n < m:               # take longest route
#            print(n, 0)
#            print(0, m)
#        else:
#            print(0, m)
#            print(n, 0)

main()


from math import *

def main():
    n, m = [int(x) for x in input().split()]
    if n == 0:
        print(0, 1)
        print(0, m)
        print(0, 0)
        print(0, m-1)
    elif m == 0:
        print(1, 0)
        print(n, 0)
        print(0, 0)
        print(n-1, 0)
    else:
        r1 = 2*sqrt(n*n + m*m) + max(n, m)
        r2 = 2*sqrt((n - 1)*(n - 1) + m*m) + sqrt(n*n + m*m)
        r3 = 2*sqrt((m - 1)*(m - 1) + n*n) + sqrt(n*n + m*m)

        if r3 > max(r1, r2):
            print(n, 1)
            print(0, m)
            print(n, 0)
            print(0, m-1)

        elif r2 > r1:
            print(n-1, m)
            print(0, 0)
            print(n, m)
            print(1, 0)

        else:
        # r1
            print(0, 0)
            print(n, m)
            if n < m:               # take longest route
                print(n, 0)
                print(0, m)
            else:
                print(0, m)
                print(n, 0)

main()


import math

if __name__=='__main__':
    (x,y) = (int(a) for a in input().split(' '))
    ans = []
    if x == 0:
##        print('Enters 1')
        ans.append((0,1))
        ans.append((0,y))
        ans.append((0,0))
        ans.append((0,y-1))
    elif y == 0:
##        print('Enters 2')
        ans.append((1,0))
        ans.append((x,0))
        ans.append((0,0))
        ans.append((x-1,0))
    else:
        if x > y:
            if (y < 2) or (math.sqrt(x**2 + y**2) + x > 2*math.sqrt(x**2 + (y-1)**2)):
##                print('Enters 3')
                ans.append((0,0))
                ans.append((x,y))
                ans.append((0,y))
                ans.append((x,0))
            else:
##                print('Enters 4')
                ans.append((0,1))
                ans.append((x,y))
                ans.append((0,0))
                ans.append((x,y-1))
        else:
            if (x < 2) or (math.sqrt(x**2 + y**2) + y > math.sqrt(y**2 + (x-1)**2) + math.sqrt(y**2 + (x-1)**2)):
##                print('Enters 5')
                ans.append((0,0))
                ans.append((x,y))
                ans.append((x,0))
                ans.append((0,y))
            else:
##                print('Enters 6')
                ans.append((1,0))
                ans.append((x,y))
                ans.append((0,0))
                ans.append((x-1,y))
    for a in ans:
        print(str(a[0])+' '+str(a[1]))


import math

if __name__=='__main__':
    (x,y) = (int(a) for a in input().split(' '))
    ans = []
    if x == 0:
##        print('Enters 1')
        ans.append((0,1))
        ans.append((0,y))
        ans.append((0,0))
        ans.append((0,y-1))
    elif y == 0:
##        print('Enters 2')
        ans.append((1,0))
        ans.append((x,0))
        ans.append((0,0))
        ans.append((x-1,0))
    else:
        if x > y:
            if (y < 2) or (math.sqrt(x**2 + y**2) + x > 2*math.sqrt(x**2 + (y-1)**2)):
##                print('Enters 3')
                ans.append((0,0))
                ans.append((x,y))
                ans.append((0,y))
                ans.append((x,0))
            else:
##                print('Enters 4')
                ans.append((0,1))
                ans.append((x,y))
                ans.append((0,0))
                ans.append((x,y-1))
        else:
            if (x < 2) or (math.sqrt(x**2 + y**2) + y > math.sqrt(y**2 + (x-1)**2) + math.sqrt(y**2 + (x-2)**2)):
##                print('Enters 5')
                ans.append((0,0))
                ans.append((x,y))
                ans.append((x,0))
                ans.append((0,y))
            else:
##                print('Enters 6')
                ans.append((1,0))
                ans.append((x,y))
                ans.append((0,0))
                ans.append((x-1,y))
    for a in ans:
        print(str(a[0])+' '+str(a[1]))


if __name__=='__main__':
    (x,y) = (int(x) for x in input().split(' '))
    ans = []
    if x == 0:
        ans.append((0,1))
        ans.append((0,y))
        ans.append((0,0))
        ans.append((0,y-1))
    elif y == 0:
        ans.append((1,0))
        ans.append((x,0))
        ans.append((0,0))
        ans.append((x-1,0))
    else:
        ans.append((0,0))
        ans.append((x,y))
        if x > y:
            ans.append((0,y))
            ans.append((x,0))
        else:
            ans.append((x,0))
            ans.append((0,y))
    for a in ans:
        print(str(a[0])+' '+str(a[1]))


import math

if __name__=='__main__':
    (x,y) = (int(x) for x in input().split(' '))
    ans = []
    if x == 0:
        ans.append((0,1))
        ans.append((0,y))
        ans.append((0,0))
        ans.append((0,y-1))
    elif y == 0:
        ans.append((1,0))
        ans.append((x,0))
        ans.append((0,0))
        ans.append((x-1,0))
    else:
        if x > y:
            if y > 1 and math.sqrt(x**2 + y**2) + x > 2*math.sqrt(x**2 + (y-1)**2):
                ans.append((0,0))
                ans.append((x,y))
                ans.append((0,y))
                ans.append((x,0))
            else:
                ans.append((0,1))
                ans.append((x,y))
                ans.append((0,0))
                ans.append((x,y-1))
        else:
            if y > 1 and math.sqrt(x**2 + y**2) + y > math.sqrt(y**2 + (x-1)**2) + math.sqrt(y**2 + (x-2)**2):
                ans.append((0,0))
                ans.append((x,y))
                ans.append((x,0))
                ans.append((0,y))
            else:
                ans.append((1,0))
                ans.append((x,y))
                ans.append((0,0))
                ans.append((x-1,y))
    for a in ans:
        print(str(a[0])+' '+str(a[1]))


import math

if __name__=='__main__':
    (x,y) = (int(x) for x in input().split(' '))
    ans = []
    if x == 0:
        ans.append((0,1))
        ans.append((0,y))
        ans.append((0,0))
        ans.append((0,y-1))
    elif y == 0:
        ans.append((1,0))
        ans.append((x,0))
        ans.append((0,0))
        ans.append((x-1,0))
    else:
        ans.append((0,0))
        ans.append((x,y))
        if x > y:
            if y > 1 and math.sqrt(x**2 + y**2) + x > math.sqrt(x**2 + (y-1)**2) + math.sqrt(x**2 + (y-2)**2):
                ans.append((0,y))
                ans.append((x,0))
            else:
                ans.append((0,1))
                ans.append((x,y-1))
        else:
            if y > 1 and math.sqrt(x**2 + y**2) + y > math.sqrt(y**2 + (x-1)**2) + math.sqrt(y**2 + (x-2)**2):
                ans.append((x,0))
                ans.append((0,y))
            else:
                ans.append((1,0))
                ans.append((x-1,y))
    for a in ans:
        print(str(a[0])+' '+str(a[1]))


def rast(i,j):
    return ((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
def ij(i,j,h,g):
    if (x[i]!=x[j] or y[i]!=y[j]) and (x[i]!=x[h] or y[i]!=y[h]) and (x[i]!=x[g] or y[i]!=y[g]) and (x[h]!=x[j] or y[h]!=y[j]) and (x[g]!=x[j] or y[g]!=y[j]) and (x[g]!=x[h] or y[g]!=y[h]):
        return True
    return False
n,m=map(int,input().split())
if n==0:
    print(0,1)
    print(0,m)
    print(0,0)
    print(0,m-1)
elif m==0:
    print(1,0)
    print(n,0)
    print(0,0)
    print(n-1,0)
else:
    x=[0,1,n-1,n,n,n,n,n-1,1,0,0,0]
    y=[0,0,0,0,1,m-1,m,m,m,m,m-1,1]
    sm=0
    for i in range(12):
        for j in range(12):
            if x[i]!=x[j] or y[i]!=y[j]:
                for h in range(12):
                    for g in range(12):
                        if sm<rast(i,j)+rast(j,h)+rast(g,h) and ij(i,j,h,g):
                            sm=rast(i,j)+rast(j,h)+rast(g,h)
                            l=[i,j,h,g]
    print(x[l[0]],y[l[0]])
    print(x[l[1]],y[l[1]])
    print(x[l[2]],y[l[2]])
    print(x[l[3]],y[l[3]])


n, m = map(int, input().split())

data = [[0, i] for i in range(min(m + 1, 3))] + [[j, 0] for j in range(min(n + 1, 3))] + [[n, k] for k in range(max(0, m - 3), m + 1)] + [[l, m] for l in range(max(n - 3, 0), n + 1)]
a, b, c, d = 0, 0, 0, 0
r = -1

def check(a, b, c, d):
    return ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5 + ((b[0] - c[0]) ** 2 + (b[1] - c[1]) ** 2) ** 0.5 + ((c[0] - d[0]) ** 2 + (c[1] - d[1]) ** 2) ** 0.5
for i in range(len(data)):
    for j in range(len(data)):
        for k in range(len(data)):
            for l in range(len(data)):
                if not (data[i] != data[k] and data[j] != data[l] and data[i] != data[j] and data[i] != data[l] and data[j] != data[k] and data[k] != data[l]):
                    continue
                if r < check(data[i], data[j], data[k], data[l]):
                    r = check(data[i], data[j], data[k], data[l])
                    #print(i, j, k, l)
                    a, b, c, d = data[i], data[j], data[k], data[l]
print(a[0], a[1])
print(b[0], b[1])
print(c[0], c[1])
print(d[0], d[1])


n, m = map(int, input().split())

data = [[0, i] for i in range(min(m + 1, 5))] + [[j, 0] for j in range(min(n + 1, 5))] + [[n, k] for k in range(max(0, m - 5), m + 1)] + [[l, m] for l in range(max(n - 5, 0), n + 1)]
a, b, c, d = 0, 0, 0, 0
r = -1

def check(a, b, c, d):
    return ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5 + ((b[0] - c[0]) ** 2 + (b[1] - c[1]) ** 2) ** 0.5 + ((c[0] - d[0]) ** 2 + (c[1] - d[1]) ** 2) ** 0.5
for i in range(len(data)):
    for j in range(len(data)):
        for k in range(len(data)):
            for l in range(len(data)):
                if not (data[i] != data[k] and data[j] != data[l] and data[i] != data[j] and data[i] != data[l] and data[j] != data[k] and data[k] != data[l]):
                    continue
                if r < check(data[i], data[j], data[k], data[l]):
                    r = check(data[i], data[j], data[k], data[l])
                    #print(i, j, k, l)
                    a, b, c, d = data[i], data[j], data[k], data[l]
print(a[0], a[1])
print(b[0], b[1])
print(c[0], c[1])
print(d[0], d[1])


def dist(a, b)
  dx = a[0]-b[0]
  dy = a[1]-b[1]
  Math.sqrt(dx*dx+dy*dy)
end

def len(arr)
  dist(arr[0],arr[1]) + dist(arr[1],arr[2]) + dist(arr[2],arr[3])
end

n, m = gets.strip.split(" ").map{|x| x.to_i}

if n == 0
  puts "0 1"
  puts "0 #{m}"
  puts "0 0"
  puts "0 #{m-1}"
  exit
end
if m == 0
  puts "1 0"
  puts "#{n} 0"
  puts "0 0"
  puts "#{n-1} 0"
  exit
end

candidates = []

candidates.push [
  [n, m-1],
  [0, 0],
  [n, m],
  [0, 1]
]
candidates.push [
  [n-1, m],
  [0, 0],
  [n, m],
  [1, 0]
]
candidates.push [
  [0, 0],
  [n, m],
  [n, 0],
  [0, m]
]
candidates.push [
  [0, 0],
  [n, m],
  [0, m],
  [n, 0]
]

candidates.sort!{|a, b| -(len(a)<=>len(b))}

puts candidates.first.map{|x| x.join(" ")}


n, m = gets.split.map &:to_i
r = false
if n > m
  n, m = m, n
  r = true
end

ans = []
if n == 0
  ans << [0, 1] << [0, m] << [0, 0] << [0, m - 1]
elsif Math.hypot(n, m) * 2 + m > Math.hypot(n, m) + Math.hypot(m, n - 1) * 2
  ans << [0, 0] << [n, m] << [n, 0] << [0, m]
else
  ans << [1, 0] << [n, m] << [0, 0] << [n - 1, m]
end

ans.each{|i|
  if !r
    puts i * ' '
  else
    puts i.reverse * ' '
  end
}


n,m=gets.split.map{|i| i.to_i}
n,m=m,n if n>m
puts "0 1"
puts "#{n} #{m}"
puts "0 0"
puts "#{n} #{m-1}"


n,m=gets.split.map{|i| i.to_i}
n,m=m,n if n>m
puts "0 0"
puts "#{n} #{m}"
puts "0 1"
puts "#{n} #{m-1}"


n,m=gets.split.map{|i| i.to_i}
r=false
if n>m
	n,m=m,n
	r=true
end
if n==m
	puts "#{n} #{m}\n0 0\n#{n} 0\n0 #{m}\n"
	exit
end
a=[]
if n==0
	a<<[0,1]<<[0,m]<<[0,0]<<[0,m-1]
else
	a<<[1,0]<<[n,m]<<[0,0]<<[n-1,m]
end
a.each{|i|
	if !r
		puts i*' '
	else
		puts i.reverse*' '
	end}


n,m=gets.split.map{|i| i.to_i}
n,m=m,n if n>m
if n+m==2
	puts "1 1\n0 0\n1 0\n0 1\n"
	exit
end

puts "0 1"
puts "#{n} #{m}"
puts "0 0"
puts "#{n} #{m-1}"


n,m=gets.split.map{|i| i.to_i}
n,m=m,n if n>m
if n+m==2
	puts "0 1\n1 1\n0 0\n1 0\n"
	exit
end

puts "0 1"
puts "#{n} #{m}"
puts "0 0"
puts "#{n} #{m-1}"


n,m=gets.split.map{|i| i.to_i}
r=false
if n>m
	n,m=m,n
	r=true
end
if n==m&&n<4
	puts "#{n} #{m}\n0 0\n#{n} 0\n0 #{m}\n"
	exit
end
a=[]
if n==0
	a<<[0,1]<<[0,m]<<[0,0]<<[0,m-1]
else
	a<<[1,0]<<[n,m]<<[0,0]<<[n-1,m]
end
a.each{|i|
	if !r
		puts i*' '
	else
		puts i.reverse*' '
	end}


n,m=gets.split.map{|i| i.to_i}
r=false
if n>m
	n,m=m,n
	r=true
end
if n+m==2
	puts "1 1\n0 0\n1 0\n0 1\n"
	exit
end
a=[]
if n==0
	a<<[0,1]<<[0,m]<<[0,0]<<[0,m-1]
else
	a<<[1,0]<<[n,m]<<[0,0]<<[n-1,m]
end
a.each{|i|
	if !r
		puts i*' '
	else
		puts i.reverse*' '
	end}


n,m=gets.split.map{|i| i.to_i}
r=false
if n>m
	n,m=m,n
	r=true
end
if n+m==2
	puts "1 1\n0 0\n1 0\n0 1\n"
	exit
end
a=[]
puts r
if n==0
	a<<[0,1]<<[0,m]<<[0,0]<<[0,m-1]
else
	a<<[1,0]<<[n,m]<<[0,0]<<[n-1,m]
end
a.each{|i|
	if !r
		puts i*' '
	else
		puts i.reverse*' '
	end}


n,m=gets.split.map{|i| i.to_i}
r=false
if n>m
	n,m=m,n
	r=true
end
if n+m==2
	puts "1 1\n0 0\n1 0\n0 1\n"
	exit
end
a=[]
if n==0
	a<<[0,1]<<[0,m]<<[0,0]<<[0,m-1]
else
	a<<[1,0]<<[n,m]<<[0,0]<<[n-1,m]
end
a.each{|i|
	if r
		puts i*' '
	else
		puts i.reverse*' '
	end}


from math import *
N,M = map(int, raw_input().split())
p=[N,M]
p.sort()
n,m = p
def d(P): a,b=P;dx=b[0]-a[0];dy=b[1]-a[1];return sqrt(dx*dx+dy*dy)
def D(C): return sum(map(d,zip(C,C[1:])))
if n:
    Q=A=[(1,0),(n,m),(0,0),(n-1,m)]
    B=[(0,0),(n,m),(n,0),(0,m)]
    if D(A)<D(B): Q=B
else:
    Q=[(0,m-1),(0,0),(0,m),(0,1)]
if N!=n: Q=[(b,a) for(a,b) in Q]
for a,b in Q: print a,b


x,y=map(int,raw_input().split())
print 0,0
print x,y
if x>y:
    if y:
        print 0,y;print x,0
    else:
        print 1,0;print x-1,0
else:
    if x:
        print x,0;print 0,y
    else:
        print 0,1;print 0,y-1


x,y=map(int,raw_input().split())
if x>y:
    if y:
        print x,y-1;print 0,0;print x,y;print 1,0
    else:
        print 1,0;print x,0;print 0,0;print x-1,0
else:
    if x:
        print x-1,y;print 0,0;print x,y;print 0,1
    else:
        print 0,1;print 0,y;print 0,0;print 0,y-1


x,y=map(int,raw_input().split())
if x>y:
    if y:
        print 0,0;print x,y;print 0,y;print x,0
    else:
        print 1,0;print x,0;print 0,0;print x-1,0
else:
    if x:
        print 0,0;print x,y;print x,0;print 0,y
    else:
        print 0,1;print 0,y;print 0,0;print 0,y-1


from math import *
N,M = map(int, raw_input().split())
p=[N,M]
p.sort()
n,m = p
def d(P): a,b=P;dx=b[0]-a[0];dy=b[1]-a[1];return sqrt(dx*dx+dy*dy)
def D(C): return sum(map(d,zip(C,C[1:])))
if n:
    Q=A=[(1,0),(n,m),(0,0),(n-1,m)]
    B=[(0,0),(n,m),(n,0),(0,m)]
    if D(A)<D(B): Q=B
else:
    Q=[(0,m-1),(0,0),(0,m),(0,1)]
if N!=n: Q=[(b,a) for(a,b) in re]
for a,b in Q: print a,b


#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys
import os
from math import sqrt

def dist(p1, p2):
    x = p1[0] - p2[0]
    y = p1[1] - p2[1]
    return sqrt(x*x+y*y)

def test(X):
    ret = 0
    for i in xrange(1, len(X)):
        ret += dist(X[i], X[i-1])
    return ret

def main():
    N, M = map(int, sys.stdin.readline().split())
    if N < M:
        N, M = M, N
        swap = True
    else:
        swap = False
    zero = ((0, 0), ) * 4
    p = ((N-1, M), (0, 0), (N, M), (1, 0))
    if M > 0:
        p1 = ((0, M), (N, 0), (0, 0), (N, M))
        if test(p1) > test(p):
            p = p1
        p1 = ((0, 1), (N, M), (0, 0), (N, M-1))
        if test(p1) > test(p):
            p = p1

    if swap:
        p = [(x, y) for (y, x) in p]
    for x, y in p:
        print x, y
    #print test(p)

if __name__ == '__main__':
    main()


#!/usr/bin/env python

from sys import stdin

import math

def dist( p1, p2 ):
   return math.sqrt( (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2 )

def dist_poly( P ):
   res = 0
   for i in xrange(1, len(P)):
      res += dist( P[i-1], P[i] )
   return res

def main():
   N, M = map(int, stdin.readline().split())
   ans = []
   if N > 0 and M > 0:
      ans1 = [ (0, 0), (N, M), (0, 1), (N, M-1) ]
      ans2 = [ (0, 0), (N, M), (1, 0), (N-1, M) ]
      res1 = dist_poly( ans1 )
      res2 = dist_poly( ans1 )
      if res1 >= res2:
         ans = ans1
      else:
         ans = ans2
   else:
      if N > 0:
         ans = [ (1, 0), (N, 0), (0, 0), (N-1, 0) ]
      else:
         ans = [ (0, 1), (0, M), (0, 0), (0, M-1) ]

   for p in ans:
      print '%d %d' % (p[0], p[1])

   return 0

if __name__ == '__main__': main()


#!/usr/bin/env python

from sys import stdin, stderr

import math
import itertools

def dist( p1, p2 ):
   return math.sqrt( (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2 )

def dist_poly( P ):
   res = 0
   for i in xrange(1, len(P)):
      res += dist( P[i-1], P[i] )
   return res

def main():
   N, M = map(int, stdin.readline().split())
   points = [ (0, 0), (N, M), (N, 0), (0, M)  ]
   if N > 0:
      points.append( (1, 0) )
      points.append( (N-1, M) )
      points.append( (N-1, 0) )
      points.append( (1, M) )

   if M > 0:
      points.append( (0, 1) )
      points.append( (N, M-1) )
      points.append( (N, 1) )
      points.append( (0, M-1) )

   points = list( set(points) )

   best_dist = 0
   for p in itertools.permutations( points, 4 ):
      d = dist_poly( p )
      if d > best_dist:
         best_dist = d
         ans = p

#  print >>stderr, '%.7f' % best_dist

   for p in ans:
      print '%d %d' % (p[0], p[1])

   return 0

if __name__ == '__main__': main()


import fileinput
import sys
import math
inp = []
for line in fileinput.input():
    inp.append(line)
#inp = raw_input().split("\n")
inp = inp[0]
n = int(inp.split(' ')[0])
m = int(inp.split(' ')[1])
x = min(m, n)
if 5 > x >= 1:
    print "0 0"
    print n, m
    print str(n)+" 0"
    print "0 "+str(m)

elif x >= 5:
    print "1 0"
    print n, m
    print "0 0"
    print str(n-1) + " " + str(m)
else:
    print "0 1"
    print "0 " + str(m)
    print "0 0"
    print "0 " + str(m-1)

##n = 3
##m = 4
##max_ = 0.0
##for ax in range(n):
##    for ay in range(m):
##        for bx in range(n):
##            for by in range(m):
##                if not(ax==bx) or not(ay==by):
##                    for cx in range(n):
##                        for cy in range(m):
##                            if (not(cx==bx) or not(cy==by)) and (not(cx==ax) or not(cy==ay)):
##                                for dx in range(n):
##                                    for dy in range(m):
##                                        if (not(dx==bx) or not(dy==by)) and (not(dx==ax) or not(dy==ay)) and (not(dx==cx) or not(dy==cy)):
##                                            asdf = math.sqrt((ax-bx)**2+(ay-by)**2)+math.sqrt((cx-bx)**2+(cy-by)**2)+math.sqrt((cx-dx)**2+(cy-dy)**2)
##                                            if asdf > max_:
##                                                good = [ax, ay, bx, by, cx, cy, dx, dy]
##                                                max_ = asdf
##print good


import fileinput
import sys
import math
inp = []
for line in fileinput.input():
    inp.append(line)
#inp = raw_input().split("\n")
inp = inp[0]
n = int(inp.split(' ')[0])
m = int(inp.split(' ')[1])
if 5 > n >= 1:
    print "0 0"
    print n, m
    print str(n)+" 0"
    print "0 "+str(m)

elif n >= 5:
    print "1 0"
    print n, m
    print "0 0"
    print str(n-1) + " " + str(m)
else:
    print "0 1"
    print "0 " + str(m)
    print "0 0"
    print "0 " + str(m-1)

##n = 3
##m = 4
##max_ = 0.0
##for ax in range(n):
##    for ay in range(m):
##        for bx in range(n):
##            for by in range(m):
##                if not(ax==bx) or not(ay==by):
##                    for cx in range(n):
##                        for cy in range(m):
##                            if (not(cx==bx) or not(cy==by)) and (not(cx==ax) or not(cy==ay)):
##                                for dx in range(n):
##                                    for dy in range(m):
##                                        if (not(dx==bx) or not(dy==by)) and (not(dx==ax) or not(dy==ay)) and (not(dx==cx) or not(dy==cy)):
##                                            asdf = math.sqrt((ax-bx)**2+(ay-by)**2)+math.sqrt((cx-bx)**2+(cy-by)**2)+math.sqrt((cx-dx)**2+(cy-dy)**2)
##                                            if asdf > max_:
##                                                good = [ax, ay, bx, by, cx, cy, dx, dy]
##                                                max_ = asdf
##print good


import fileinput
import sys
import math
inp = []
for line in fileinput.input():
    inp.append(line)
#inp = raw_input().split("\n")
inp = inp[0]
n = int(inp.split(' ')[0])
m = int(inp.split(' ')[1])
if n >= 1:
    print "1 0"
    print n, m
    print "0 0"
    print str(n-1) + " " + str(m)
else:
    print "0 1"
    print "0 " + str(m)
    print "0 0"
    print "0 " + str(m-1)
##max_ = 0.0
##for ax in range(5):
##    for ay in range(5):
##        for bx in range(5):
##            for by in range(5):
##                if not(ax==bx) or not(ay==by):
##                    for cx in range(5):
##                        for cy in range(5):
##                            if (not(cx==bx) or not(cy==by)) and (not(cx==ax) or not(cy==ay)):
##                                for dx in range(5):
##                                    for dy in range(5):
##                                        if (not(dx==bx) or not(dy==by)) and (not(dx==ax) or not(dy==ay)) and (not(dx==cx) or not(dy==cy)):
##                                            asdf = math.sqrt((ax-bx)**2+(ay-by)**2)+math.sqrt((cx-bx)**2+(cy-by)**2)+math.sqrt((cx-dx)**2+(cy-dy)**2)
##                                            if asdf > max_:
##                                                good = [ax, ay, bx, by, cx, cy, dx, dy]
##                                                max_ = asdf


import fileinput
import sys
inp = []
for line in fileinput.input():
    inp.append(line)
#inp = raw_input().split("\n")
inp = inp[0]
n = int(inp.split(' ')[0])
m = int(inp.split(' ')[1])
if n >= 1:
    print "0 0"
    print n, m
    print "1 0"
    print str(n-1) + " " + str(m)
else:
    print "0 1"
    print "0 " + str(m)
    print "0 0"
    print "0 " + str(m-1)


import fileinput
import sys
import math
inp = []
for line in fileinput.input():
    inp.append(line)
#inp = raw_input().split("\n")
inp = inp[0]
n = int(inp.split(' ')[0])
m = int(inp.split(' ')[1])
if n <= m:
    if 4 > n >= 1:
        print "0 0"
        print n, m
        print str(n)+" 0"
        print "0 "+str(m)

    elif n >= 4:
        print "1 0"
        print n, m
        print "0 0"
        print str(n-1) + " " + str(m)
    else:
        print "0 1"
        print "0 " + str(m)
        print "0 0"
        print "0 " + str(m-1)
else:
    if 4 > m >= 1:
        print "0 0"
        print n, m
        print "0 "+str(m)
        print str(n)+" 0"

    elif m >= 4:
        print "0 1"
        print n, m
        print "0 0"
        print str(n) + " " + str(m-1)
    else:
        print "1 0"
        print str(n) + " 0"
        print "0 0"
        print str(n-1) + " 0"

##n = 3
##m = 4
##max_ = 0.0
##for ax in range(n):
##    for ay in range(m):
##        for bx in range(n):
##            for by in range(m):
##                if not(ax==bx) or not(ay==by):
##                    for cx in range(n):
##                        for cy in range(m):
##                            if (not(cx==bx) or not(cy==by)) and (not(cx==ax) or not(cy==ay)):
##                                for dx in range(n):
##                                    for dy in range(m):
##                                        if (not(dx==bx) or not(dy==by)) and (not(dx==ax) or not(dy==ay)) and (not(dx==cx) or not(dy==cy)):
##                                            asdf = math.sqrt((ax-bx)**2+(ay-by)**2)+math.sqrt((cx-bx)**2+(cy-by)**2)+math.sqrt((cx-dx)**2+(cy-dy)**2)
##                                            if asdf > max_:
##                                                good = [ax, ay, bx, by, cx, cy, dx, dy]
##                                                max_ = asdf
##print good


import fileinput
import sys
import math
inp = []
for line in fileinput.input():
    inp.append(line)
#inp = raw_input().split("\n")
inp = inp[0]
n = int(inp.split(' ')[0])
m = int(inp.split(' ')[1])
if n <= m:
    if 5 > n >= 1:
        print "0 0"
        print n, m
        print str(n)+" 0"
        print "0 "+str(m)

    elif n >= 5:
        print "1 0"
        print n, m
        print "0 0"
        print str(n-1) + " " + str(m)
    else:
        print "0 1"
        print "0 " + str(m)
        print "0 0"
        print "0 " + str(m-1)
else:
    if 5 > m >= 1:
        print "0 0"
        print n, m
        print "0 "+str(m)
        print str(n)+" 0"

    elif m >= 5:
        print "0 1"
        print n, m
        print "0 0"
        print str(n) + " " + str(m-1)
    else:
        print "1 0"
        print str(n) + " 0"
        print "0 0"
        print str(n-1) + " 0"

##n = 3
##m = 4
##max_ = 0.0
##for ax in range(n):
##    for ay in range(m):
##        for bx in range(n):
##            for by in range(m):
##                if not(ax==bx) or not(ay==by):
##                    for cx in range(n):
##                        for cy in range(m):
##                            if (not(cx==bx) or not(cy==by)) and (not(cx==ax) or not(cy==ay)):
##                                for dx in range(n):
##                                    for dy in range(m):
##                                        if (not(dx==bx) or not(dy==by)) and (not(dx==ax) or not(dy==ay)) and (not(dx==cx) or not(dy==cy)):
##                                            asdf = math.sqrt((ax-bx)**2+(ay-by)**2)+math.sqrt((cx-bx)**2+(cy-by)**2)+math.sqrt((cx-dx)**2+(cy-dy)**2)
##                                            if asdf > max_:
##                                                good = [ax, ay, bx, by, cx, cy, dx, dy]
##                                                max_ = asdf
##print good


import fileinput
import sys
import math
inp = []
for line in fileinput.input():
    inp.append(line)
#inp = raw_input().split("\n")
inp = inp[0]
n = int(inp.split(' ')[0])
m = int(inp.split(' ')[1])
if n <= m:
    if 5 > n >= 1:
        print "0 0"
        print n, m
        print str(n)+" 0"
        print "0 "+str(m)

    elif n >= 5:
        print "1 0"
        print n, m
        print "0 0"
        print str(n-1) + " " + str(m)
    else:
        print "0 1"
        print "0 " + str(m)
        print "0 0"
        print "0 " + str(m-1)
else:
    if 5 > m >= 1:
        print "0 0"
        print n, m
        print str(n)+" 0"
        print "0 "+str(m)

    elif m >= 5:
        print "0 1"
        print n, m
        print "0 0"
        print str(n) + " " + str(m-1)
    else:
        print "1 0"
        print str(n) + " 0"
        print "0 0"
        print str(n-1) + " 0"

##n = 3
##m = 4
##max_ = 0.0
##for ax in range(n):
##    for ay in range(m):
##        for bx in range(n):
##            for by in range(m):
##                if not(ax==bx) or not(ay==by):
##                    for cx in range(n):
##                        for cy in range(m):
##                            if (not(cx==bx) or not(cy==by)) and (not(cx==ax) or not(cy==ay)):
##                                for dx in range(n):
##                                    for dy in range(m):
##                                        if (not(dx==bx) or not(dy==by)) and (not(dx==ax) or not(dy==ay)) and (not(dx==cx) or not(dy==cy)):
##                                            asdf = math.sqrt((ax-bx)**2+(ay-by)**2)+math.sqrt((cx-bx)**2+(cy-by)**2)+math.sqrt((cx-dx)**2+(cy-dy)**2)
##                                            if asdf > max_:
##                                                good = [ax, ay, bx, by, cx, cy, dx, dy]
##                                                max_ = asdf
##print good


from math import *

import sys
stdin = sys.stdin

N, M = map(int, stdin.readline().strip().split())
nm = [N, M]
nm.sort()
n, m = nm

def dist(ab):
    a, b = ab
    dx = b[0] - a[0]
    dy = b[1] - a[1]
    return sqrt(dx*dx + dy*dy)

if 0 == n:
    re = [(0, m-1), (0, 0), (0, m), (0, 1)]
else:
    c1 = [(1, 0), (n, m), (0, 0), (n-1, m)]
    c2 = [(0, 0), (n, m), (n, 0), (0, m)]
    re = c1
    if sum(map(dist, zip(c1, c1[1:]))) \
    <  sum(map(dist, zip(c2, c2[1:]))):
        re = c2

if N != n:
    re = [(b, a) for (a, b) in re]
for a, b in re:
    print a, b


#!/usr/bin/python
import sys

def Ni(): return tuple(map(int, sys.stdin.readline().split()))

n, m = Ni()

Flipped = False

#assert n <= m
if m < n:
    m, n = n, m
    Flipped = True

assert n <= m

LC = set([(0, 0), (0, min(1, m)), (min(1, n), 0)])
RC = set([(n, m), (n, max(m-1, 0)), (max(n-1, 0), m)])
#print LC
#print RC

from math import sqrt
from itertools import combinations

def d((x0, y0), (x1, y1)):
    return sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1))

def total(p0, p1, p2, p3):
    return d(p0, p1) + d(p1, p2) + d(p2, p3)

best = None

if n > 0:
    best = [(0,0), (n, m), (n, 0), (0, m)]
    bestDistance = total(*best)

for p0 in LC:
    for p1 in RC - set((p0,)):
        for p2 in LC - set((p0,p1,)):
            for p3 in RC - set((p0,p1,p2)):
                thisD = total(p0, p1, p2, p3)
                #print p0, p1, p2, p3, thisD
                if best == None or thisD > bestDistance:
                    bestDistance = thisD
                    best = [ p0, p1, p2, p3 ]

#print best

for x, y in best:
    if Flipped:
        print y, x
    else:
        print x, y


#!/usr/bin/python
import sys

def Ni(): return tuple(map(int, sys.stdin.readline().split()))

n, m = Ni()

Flipped = False

#assert n <= m
if m < n:
    m, n = n, m
    Flipped = True

assert n <= m

LC = set([(0, 0), (0, min(1, m)), (min(1, n), 0)])
RC = set([(n, m), (n, max(m-1, 0)), (max(n-1, 0), m)])
#print LC
#print RC

from math import sqrt
from itertools import combinations

def d((x0, y0), (x1, y1)):
    return sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1))

def total(p0, p1, p2, p3):
    return d(p0, p1) + d(p1, p2) + d(p2, p3)

best = None

if n > 0:
    best = [(0,0), (n, m), (0, m), (n, 0)]
    bestDistance = total(*best)

for p0 in LC:
    for p1 in RC - set((p0,)):
        for p2 in LC - set((p0,p1,)):
            for p3 in RC - set((p0,p1,p2)):
                thisD = total(p0, p1, p2, p3)
                #print p0, p1, p2, p3, thisD
                if best == None or thisD > bestDistance:
                    bestDistance = thisD
                    best = [ p0, p1, p2, p3 ]

#print best

for x, y in best:
    if Flipped:
        print y, x
    else:
        print x, y


#!/usr/bin/python
import sys

def Ni(): return tuple(map(int, sys.stdin.readline().split()))

n, m = Ni()

Flipped = False

#assert n <= m
if m < n:
    m, n = n, m
    Flipped = True

a = []
assert n <= m
if n == m == 0:
    a = [(0, 0)] * 4
elif n == 0:
    a.append((0, 1))
    a.append((0, m))
    a.append((0, 0))
    a.append((0, m-1))
else:
    a.append((0, 0))
    a.append((n, m))
    a.append((1, 0))
    a.append((n-1, m))

for x, y in a:
    if Flipped:
        print y, x
    else:
        print x, y


#!/usr/bin/python
import sys

def Ni(): return tuple(map(int, sys.stdin.readline().split()))

n, m = Ni()

Flipped = False

#assert n <= m
if m < n:
    m, n = n, m
    Flipped = True

a = []
if n == 0:
    a.append((0, 1))
    a.append((0, m))
    a.append((0, 0))
    a.append((0, m-1))
else:
    a.append((0, 0))
    a.append((n, m))
    a.append((n, 0))
    a.append((0, m))

for x, y in a:
    if Flipped:
        print y, x
    else:
        print x, y


#!/usr/bin/python
import sys

def Ni(): return tuple(map(int, sys.stdin.readline().split()))

n, m = Ni()

Flipped = False

#assert n <= m
if m < n:
    m, n = n, m
    Flipped = True

assert n <= m

LC = set([(0, 0), (0, min(1, m)), (min(1, n), 0)])
RC = set([(n, m), (n, max(m-1, 0)), (max(n-1, 0), m)])
#print LC
#print RC

from math import sqrt
from itertools import combinations

def d((x0, y0), (x1, y1)):
    return sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1))

def total(p0, p1, p2, p3):
    return d(p0, p1) + d(p1, p2) + d(p2, p3)

best = None
for p0 in LC:
    for p1 in RC - set((p0,)):
        for p2 in LC - set((p0,p1,)):
            for p3 in RC - set((p0,p1,p2)):
                thisD = total(p0, p1, p2, p3)
                #print p0, p1, p2, p3, thisD
                if best == None or thisD > bestDistance:
                    bestDistance = thisD
                    best = [ p0, p1, p2, p3 ]

#print best

for x, y in best:
    if Flipped:
        print y, x
    else:
        print x, y


import math
s = raw_input()
s = s.split( )
x = int(s[0])
y = int(s[1])

def diff1 (x, y):
    s1 = 2 * (math.sqrt ((x*x) + (y-1)*(y-1)))
    s2 = x + math.sqrt (x*x + y*y)
    return s1 - s2
def diff2 (x, y):
    s1 = 2 * (math.sqrt ((y*y) + (x-1)*(x-1)))
    s2 = y + math.sqrt (x*x + y*y)
    return s1 - s2

if x == 0:
    print "0 1"
    print x, y
    print "0 0"
    print x, y-1
elif y == 0:
    print "1 0"
    print x, y
    print "0 0"
    print x-1, y
else:
    if x > y:
        if diff1 (x, y) > 0:
            print "0 1"
            print x, y
            print "0 0"
            print x, y-1
        else:
            print "0 0"
            print x, y
            print "0", y
            print x, "0"
    else:
        if diff2 (x, y) > 0:
            print "1 0"
            print x, y
            print "0 0"
            print x-1, y
        else:
            print "0 0"
            print x, y
            print x, "0"
            print "0", y


s = raw_input()
s = s.split( )
x = int(s[0])
y = int(s[1])
if x > y:
    print '0 1'
    print x, y
    print '0 0'
    print x, y-1
else:
    print '1 0'
    print x, y
    print '0 0'
    print x-1, y


import math
s = raw_input()
s = s.split( )
x = int(s[0])
y = int(s[1])

def diff1 (x, y):
    s1 = 2 * (math.sqrt ((x*x) + (y-1)*(y-1)))
    s2 = x + math.sqrt (x*x + y*y)
    return s1 - s2
def diff2 (x, y):
    s1 = 2 * (math.sqrt ((y*y) + (x-1)*(x-1)))
    s2 = y + math.sqrt (x*x + y*y)
    return s1 - s2

if x == 0:
    print "0 1"
    print x, y
    print "0 0"
    print x, y-1
elif y == 0:
    print "1 0"
    print x, y
    print "0 0"
    print x-1, y
else:
    if x > y:
        if diff1 (x, y) > 0:
            print "0 1"
            print x, y
            print "0 0"
            print x-1, y
        else:
            print "0 0"
            print x, y
            print "0", y
            print x, "0"
    else:
        if diff2 (x, y) > 0:
            print "1 0"
            print x, y
            print "0 0"
            print x, y-1
        else:
            print "0 0"
            print x, y
            print x, "0"
            print "0", y


s = raw_input()
s = s.split( )
x = int(s[0])
y = int(s[1])
if x == 0:
    print "0 1"
    print x, y
    print "0 0"
    print x, y-1
elif y == 0:
    print "1 0"
    print x, y
    print "0 0"
    print x-1, y
else:
    if x > y:
        print "0 0"
        print x, y
        print "0", y
        print x, "0"
    else:
        print "0 0"
        print x, y
        print x, "0"
        print "0", y


import math
s = raw_input()
s = s.split( )
x = int(s[0])
y = int(s[1])

def diff1 (x, y):
    s1 = 2 * (math.sqrt ((y*y) + (x-1)*(x-1)))
    s2 = x + math.sqrt (x*x + y*y)
    return s1 - s2
def diff2 (x, y):
    s1 = 2 * (math.sqrt ((x*x) + (y-1)*(y-1)))
    s2 = y + math.sqrt (x*x + y*y)
    return s1 - s2

if x == 0:
    print "0 1"
    print x, y
    print "0 0"
    print x, y-1
elif y == 0:
    print "1 0"
    print x, y
    print "0 0"
    print x-1, y
else:
    if x > y:
        if diff1 (x, y) > 0:
            print "1 0"
            print x, y
            print "0 0"
            print x, y-1
        else:
            print "0 0"
            print x, y
            print "0", y
            print x, "0"
    else:
        if diff2 (x, y) > 0:
            print "0 1"
            print x, y
            print "0 0"
            print x-1, y
        else:
            print "0 0"
            print x, y
            print x, "0"
            print "0", y


import math
s = raw_input()
s = s.split( )
x = int(s[0])
y = int(s[1])

def diff1 (x, y):
    s1 = 2 * (math.sqrt ((x*x) + (y-1)*(y-1)))
    s2 = x + math.sqrt (x*x + y*y)
    return s1 - s2
def diff2 (x, y):
    s1 = 2 * (math.sqrt ((y*y) + (x-1)*(x-1)))
    s2 = y + math.sqrt (x*x + y*y)
    return s1 - s2

if x == 0:
    print "0 1"
    print x, y
    print "0 0"
    print x, y-1
elif y == 0:
    print "1 0"
    print x, y
    print "0 0"
    print x-1, y
else:
    if x > y:
        if diff1 (x, y) > 0:
            print "1 0"
            print x, y
            print "0 0"
            print x, y-1
        else:
            print "0 0"
            print x, y
            print "0", y
            print x, "0"
    else:
        if diff2 (x, y) > 0:
            print "0 1"
            print x, y
            print "0 0"
            print x-1, y
        else:
            print "0 0"
            print x, y
            print x, "0"
            print "0", y


n,m=map(int,raw_input().split())
import math
if(n!=0 and m!=0):
	print "0 0"
	print n,m

#	x=math.sqrt(n*n+m*m)+float(n)
#	y=math.sqrt(4*n*n+m*m)
#	z=math.sqrt(n*n+m*m)+math.sqrt(n*n+(m-1)**2)+math.sqrt(n*n+(m-2)**2);
#	print x,y,z

	if(n>m):
#		print x,y
#		if(x>y):
#		print "0",1
		ma=0.0
		yy=0
		for i in range(1,m+1):
			x=math.sqrt(n*n+(m-i)**2)
			if(ma<x):
				yy=i
				ma=x

		print "0",yy
		ma=0.0
		yyy=0
		for i in range(0,m):
			x=math.sqrt(n*n+(i-yy)**2)
			if(ma<x):
				yyy=i
				ma=x
		print n,yyy

#		else:
#		print "0",math.ceil(m/2)
#		print n,"0"
	else:
#		if(x>y):

		ma=0.0
		xx=0
		for i in range(1,n+1):
			x=math.sqrt((n-i)**2+m*m)
			if(ma<x):
				xx=i
				ma=x
		print xx,0
		ma=0.0
		xxx=0
		for i in range(0,m):
			x=math.sqrt((xx-i)**2+m*m)
			if(ma<x):
				xxx=i
				ma=x
		print xxx,m
#		else:
#		print math.ceil(n/2),"0"
#			print "0",m

elif(n==0):
	print "0 1"
	print "0",m
	print "0 0"
	print "0",m-1
else:
	print "1 0"
	print n,"0"
	print "0 0"
	print n-1,"0"


n,m=map(int,raw_input().split())
import math

if(n!=0 and m!=0):
	ch=0
	if(n<m):
		tmp=m
		m=n
		n=tmp
		ch=1

	d=2.0*math.sqrt(n*n+m*m)+float(n)
	s=2.0*math.sqrt(n*n+(m-1)*(m-1))+math.sqrt(n*n+m*m)

	x=[-1]*4
	y=[-1]*4

	if(d>s):
		x[0]=0
		y[0]=0
		x[1]=n
		y[1]=m
		x[2]=0
		y[2]=m
		x[3]=n
		y[3]=0

	else:
		x[0]=0
		y[0]=1
		x[1]=n
		y[1]=m
		x[2]=0
		y[2]=0
		x[3]=n
		y[3]=m-1

	if(ch==0):
		for i in range(0,4):
			print x[i],y[i]
	else:
		for i in range(0,4):
			print y[i],x[i]
else:
	if(n==0):
		print "0 1"
		print 0,m
		print 0,0
		print 0,m-1
	else:
		print 1,0
		print n,0
		print 0,0
		print n-1,0


n,m=map(int,raw_input().split())

if(n!=0 and m!=0):
	print "0 0"
	print n,m
	if(n>m):
		print "0",m
		print n,"0"
	else:
		print n,"0"
		print "0",m

elif(n==0):
	print "0 1"
	print "0",m
	print "0 0"
	print "0",m-1
else:
	print "1 0"
	print n,"0"
	print "0 0"
	print n-1,"0"


n,m=map(int,raw_input().split())
import math
if(n!=0 and m!=0):
	print "0 0"
	print n,m

	x=math.sqrt(n*n+m*m)+float(n)
	y=math.sqrt(4*n*n+m*m)
	z=math.sqrt(n*n+m*m)+math.sqrt(n*n+(m-1)**2)+math.sqrt(n*n+(m-2)**2);
#	print x,y,z
	if(n>m):
#		print x,y
#		if(x>y):
		print "0",1
		x=math.sqrt(n*n+(m-2)**2)
		y=math.sqrt(n*n+1)
		if(x>y):

			print n,m-1
		else:
			print n,"0"
#		else:
#		print "0",math.ceil(m/2)
#		print n,"0"
	else:
#		if(x>y):

		print 1,"0"
		x=math.sqrt(m*m+(n-2)**2)
		y=math.sqrt(m*m+1)
		if(x>y):
			print n-1,m
		else:
			print "0",m
#		else:
#		print math.ceil(n/2),"0"
#			print "0",m

elif(n==0):
	print "0 1"
	print "0",m
	print "0 0"
	print "0",m-1
else:
	print "1 0"
	print n,"0"
	print "0 0"
	print n-1,"0"


import itertools

n, m = map(int, raw_input().split())

v = [(0, 0), (0, 1), (1, 0), (1, 1), (n, m), (n-1, m), (n, m-1), (n-1, m-1), (n, 0), (0, m), (n-1, 0), (0, m-1), (n, 1), (1, m)]

v = [x for x in set(v) if x[0] >= 0 and x[0] <= n and x[1] >= 0 and x[1] <= m]

def dist(a, b):
	return (b[0]-a[0])**2 + (b[1]-a[1])**2

def line(a, b, c, d):
	return dist(a, b) + dist(b, c) + dist(c, d)

longest = 0
sol = []

for i in range(0, len(v)):
	for j in range(i+1, len(v)):
		for k in range(j+1, len(v)):
			for l in range(k+1, len(v)):

				for w in itertools.permutations([v[i], v[j], v[k], v[l]]):
					length = line(w[0], w[1], w[2], w[3])
					if length >= longest:
						longest = length
						sol = w

for x in sol:
	print "%i %i" % x


package CF.R93;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class D {
    private final static int U = 88;
    private static long fib[] = new long[U + 1];
    private static long sum[] = new long[U + 1];
    private static Map<Pair<Long, Integer>, Integer> mp;

    private static int cal(long n, int u) {
        if (n < 0) return 0;
        if (n > sum[u]) return 0;
        Pair<Long, Integer> cs = new Pair<Long, Integer>(n, u);
        if (mp.containsKey(cs)) return mp.get(cs);
        int cd = 0;
        if (n == 0) {
            cd = 1;
        } else if (u > 0 && n > 0) {
            for (int i = 0; i < u; i++)
                cd += cal(n - fib[i + 1], i);
        }
        mp.put(cs, cd);
        // System.out.println(n + " " + u + " : " + cd);
        return cd;
    }

    public static void main(String[] args) throws IOException {
        fib[1] = 1;
        fib[2] = 2;
        for (int i = 3; i <= U; i++)
            fib[i] = fib[i - 1] + fib[i - 2];
        sum[0] = 0;
        for (int i = 1; i <= U; i++)
            sum[i] = sum[i - 1] + fib[i];
//        for (int i = 1; i <= U; i++)System.out.println(sum[i]);
        Scanner cin = new Scanner(System.in);
        int T = cin.nextInt();
        mp = new HashMap<Pair<Long, Integer>, Integer>();
        for (int i = 0; i < T; i++) {
            long n = cin.nextLong();
//            long n = i + 1;
            mp.clear();
            System.out.println(cal(n, U));
        }
    }
}

class Pair<A, B> {
    private A first;
    private B second;

    public Pair(A first, B second) {
        this.first = first;
        this.second = second;
    }

    public int hashCode() {
        int hashFirst = first != null ? first.hashCode() : 0;
        int hashSecond = second != null ? second.hashCode() : 0;

        return (hashFirst + hashSecond) * hashSecond + hashFirst;
    }

    public boolean equals(Object other) {
        if (other instanceof Pair) {
            Pair otherPair = (Pair<A, B>) other;
            return ((this.first == otherPair.first || (this.first != null
                    && otherPair.first != null && this.first
                        .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null
                    && otherPair.second != null && this.second
                        .equals(otherPair.second))));
        }

        return false;
    }

    public String toString() {
        return "(" + first.toString() + ", " + second.toString() + ")";
    }

    public A getFirst() {
        return first;
    }

    public void setFirst(A first) {
        this.first = first;
    }

    public B getSecond() {
        return second;
    }

    public void setSecond(B second) {
        this.second = second;
    }
}


import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    private final static int U = 88;
    private static long fib[] = new long[U + 1];
    private static long sum[] = new long[U + 1];
    private static Map<Pair<Long, Integer>, Integer> mp;

    private static int cal(long n, int u) {
        if (n < 0) return 0;
        if (n > sum[u]) return 0;
        Pair<Long, Integer> cs = new Pair<Long, Integer>(n, u);
        if (mp.containsKey(cs)) return mp.get(cs);
        int cd = 0;
        if (n == 0) {
            cd = 1;
        } else if (u > 0 && n > 0) {
            for (int i = 0; i < u; i++)
                cd += cal(n - fib[i + 1], i);
        }
        mp.put(cs, cd);
        // System.out.println(n + " " + u + " : " + cd);
        return cd;
    }

    public static void main(String[] args) throws IOException {
        fib[1] = 1;
        fib[2] = 2;
        for (int i = 3; i <= U; i++)
            fib[i] = fib[i - 1] + fib[i - 2];
        sum[0] = 0;
        for (int i = 1; i <= U; i++)
            sum[i] = sum[i - 1] + fib[i];
        for (int i = 1; i <= U; i++)System.out.println(sum[i]);
        Scanner cin = new Scanner(System.in);
        int T = cin.nextInt();
        mp = new HashMap<Pair<Long, Integer>, Integer>();
        for (int i = 0; i < T; i++) {
            long n = cin.nextLong();
//            long n = i + 1;
            mp.clear();
            System.out.println(n + " : " + cal(n, U) + " " + mp.size());
        }
    }
}

class Pair<A, B> {
    private A first;
    private B second;

    public Pair(A first, B second) {
        this.first = first;
        this.second = second;
    }

    public int hashCode() {
        int hashFirst = first != null ? first.hashCode() : 0;
        int hashSecond = second != null ? second.hashCode() : 0;

        return (hashFirst + hashSecond) * hashSecond + hashFirst;
    }

    public boolean equals(Object other) {
        if (other instanceof Pair) {
            Pair otherPair = (Pair<A, B>) other;
            return ((this.first == otherPair.first || (this.first != null
                    && otherPair.first != null && this.first
                        .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null
                    && otherPair.second != null && this.second
                        .equals(otherPair.second))));
        }

        return false;
    }

    public String toString() {
        return "(" + first.toString() + ", " + second.toString() + ")";
    }

    public A getFirst() {
        return first;
    }

    public void setFirst(A first) {
        this.first = first;
    }

    public B getSecond() {
        return second;
    }

    public void setSecond(B second) {
        this.second = second;
    }
}


import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    private final static int U = 88;
    private static long fib[] = new long[U + 1];
    private static long sum[] = new long[U + 1];
    private static Map<Pair<Long, Integer>, Integer> mp;

    private static int cal(long n, int u) {
        if (n < 0) return 0;
        if (n > sum[u]) return 0;
        Pair<Long, Integer> cs = new Pair<Long, Integer>(n, u);
        if (mp.containsKey(cs)) return mp.get(cs);
        int cd = 0;
        if (n == 0) {
            cd = 1;
        } else if (u > 0 && n > 0) {
            for (int i = 0; i < u; i++)
                cd += cal(n - fib[i + 1], i);
        }
        mp.put(cs, cd);
        // System.out.println(n + " " + u + " : " + cd);
        return cd;
    }

    public static void main(String[] args) throws IOException {
        fib[1] = 1;
        fib[2] = 2;
        for (int i = 3; i <= U; i++)
            fib[i] = fib[i - 1] + fib[i - 2];
        sum[0] = 0;
        for (int i = 1; i <= U; i++)
            sum[i] = sum[i - 1] + fib[i];
        for (int i = 1; i <= U; i++)System.out.println(sum[i]);
        Scanner cin = new Scanner(System.in);
        int T = cin.nextInt();
        mp = new HashMap<Pair<Long, Integer>, Integer>();
        for (int i = 0; i < T; i++) {
            long n = cin.nextLong();
//            long n = i + 1;
            mp.clear();
            System.out.println(cal(n, U));
        }
    }
}

class Pair<A, B> {
    private A first;
    private B second;

    public Pair(A first, B second) {
        this.first = first;
        this.second = second;
    }

    public int hashCode() {
        int hashFirst = first != null ? first.hashCode() : 0;
        int hashSecond = second != null ? second.hashCode() : 0;

        return (hashFirst + hashSecond) * hashSecond + hashFirst;
    }

    public boolean equals(Object other) {
        if (other instanceof Pair) {
            Pair otherPair = (Pair<A, B>) other;
            return ((this.first == otherPair.first || (this.first != null
                    && otherPair.first != null && this.first
                        .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null
                    && otherPair.second != null && this.second
                        .equals(otherPair.second))));
        }

        return false;
    }

    public String toString() {
        return "(" + first.toString() + ", " + second.toString() + ")";
    }

    public A getFirst() {
        return first;
    }

    public void setFirst(A first) {
        this.first = first;
    }

    public B getSecond() {
        return second;
    }

    public void setSecond(B second) {
        this.second = second;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    private final static int U = 88;
    private static long fib[] = new long[U + 1];
    private static long sum[] = new long[U + 1];
    private static HashMap<Pair<Long, Integer>, Integer> mp;

    private static int cal(long n, int u) {
        if (n < 0) return 0;
        if (n > sum[u]) return 0;
        Pair<Long, Integer> cs = new Pair<Long, Integer>(n, u);
        if (mp.containsKey(cs)) return mp.get(cs);
        int cd = 0;
        if (n == 0) {
            cd = 1;
        } else if (u > 0 && n > 0) {
            for (int i = 0; i < u; i++)
                cd += cal(n - fib[i + 1], i);
        }
        mp.put(cs, cd);
        return cd;
    }

    public static void main(String[] args) throws IOException {
        fib[1] = 1;
        fib[2] = 2;
        for (int i = 3; i <= U; i++)
            fib[i] = fib[i - 1] + fib[i - 2];
        sum[0] = 0;
        for (int i = 1; i <= U; i++)
            sum[i] = sum[i - 1] + fib[i];
        BufferedReader stdin = new BufferedReader(new InputStreamReader(
                System.in));
        StringTokenizer st;
        st = new StringTokenizer(stdin.readLine());
        int T = Integer.parseInt(st.nextToken());
        mp = new HashMap<Pair<Long, Integer>, Integer>();
        for (int i = 0; i < T; i++) {
            st = new StringTokenizer(stdin.readLine());
            long n = Long.parseLong(st.nextToken());
            mp.clear();
            System.out.println(cal(n, U));
        }
    }
}

class Pair<A, B> {
    private A first;
    private B second;

    public Pair(A first, B second) {
        this.first = first;
        this.second = second;
    }

    public int hashCode() {
        int hashFirst = first != null ? first.hashCode() : 0;
        int hashSecond = second != null ? second.hashCode() : 0;

        return (hashFirst + hashSecond) * hashSecond + hashFirst;
    }

    public boolean equals(Object other) {
        if (other instanceof Pair) {
            Pair otherPair = (Pair<A, B>) other;
            return ((this.first == otherPair.first || (this.first != null
                    && otherPair.first != null && this.first
                        .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null
                    && otherPair.second != null && this.second
                        .equals(otherPair.second))));
        }

        return false;
    }

    public String toString() {
        return "(" + first.toString() + ", " + second.toString() + ")";
    }

    public A getFirst() {
        return first;
    }

    public void setFirst(A first) {
        this.first = first;
    }

    public B getSecond() {
        return second;
    }

    public void setSecond(B second) {
        this.second = second;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        long ct = System.currentTimeMillis();
        int U = 89;
        long fib[] = new long[U];
        fib[1] = 1;
        fib[2] = 2;
        for (int i = 3; i < U; i++)
            fib[i] = fib[i - 1] + fib[i - 2];
        int u[] = new int[U];
        BufferedReader stdin = new BufferedReader(new InputStreamReader(
                System.in));
        StringTokenizer st;
        st = new StringTokenizer(stdin.readLine());
        int T = Integer.parseInt(st.nextToken());
//        int T = 100000;
        for (int tc = 0; tc < T; tc++) {
            st = new StringTokenizer(stdin.readLine());
            long n = Long.parseLong(st.nextToken());
//            long n = (long) (Math.random() * 1000000000000000000L);
            int un = 0;
            for (int i = U - 1; i > 0; i--)
                if (n >= fib[i]) {
                    u[un++] = i;
                    n -= fib[i];
                }
            int f0 = 1, f1 = 0;
            u[un] = 0;
            for (int i = un - 1; i >= 0; i--) {
                int cd = u[i] - u[i + 1];
                int g0 = f0 + f1;
                int g1 = (cd - 1) / 2 * f0 + cd / 2 * f1;
                f0 = g0;
                f1 = g1;
            }
            System.out.println(f0 + f1);
        }
        long elapsed = System.currentTimeMillis() - ct;
        System.out.println("Using time = " + elapsed);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
//        long ct = System.currentTimeMillis();
        int U = 89;
        long fib[] = new long[U];
        fib[1] = 1;
        fib[2] = 2;
        for (int i = 3; i < U; i++)
            fib[i] = fib[i - 1] + fib[i - 2];
        int u[] = new int[U];
        BufferedReader stdin = new BufferedReader(new InputStreamReader(
                System.in));
        StringTokenizer st;
        st = new StringTokenizer(stdin.readLine());
        int T = Integer.parseInt(st.nextToken());
//        int T = 100000;
        for (int tc = 0; tc < T; tc++) {
            st = new StringTokenizer(stdin.readLine());
            long n = Long.parseLong(st.nextToken());
//            long n = (long) (Math.random() * 1000000000000000000L);
            int un = 0;
            for (int i = U - 1; i > 0; i--)
                if (n >= fib[i]) {
                    u[un++] = i;
                    n -= fib[i];
                }
            int f0 = 1, f1 = 0;
            u[un] = 0;
            for (int i = un - 1; i >= 0; i--) {
                int cd = u[i] - u[i + 1];
                int g0 = f0 + f1;
                int g1 = (cd - 1) / 2 * f0 + cd / 2 * f1;
                f0 = g0;
                f1 = g1;
            }
            System.out.println(f0 + f1);
        }
//        long elapsed = System.currentTimeMillis() - ct;
//        System.out.println("Using time = " + elapsed);
    }
}


import java.util.*;
public class r126D {
	static long[] fibNumbers;
	static TreeSet<Long> fibNums;
	static long N;
	static int i;
	static TreeSet<Long> fibs;
	static HashMap<Long, Integer> map;
	static long[] sums;
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		fibNumbers = new long[86];
		fibs = new TreeSet<Long>();
		fibNumbers[0] = 1;
		fibNumbers[1] = 2;
		fibs.add(1l);
		fibs.add(2l);
		i = 0;
		while(true) {
			if(fibNumbers[i]+fibNumbers[i+1] > 1e18)
				break;
			fibNumbers[i+2] = fibNumbers[i+1] + fibNumbers[i];
			fibs.add(fibNumbers[i+2]);
			i++;
		}

		sums = new long[87];
		i = 0;
		map = new HashMap<Long, Integer>();
		for(long fib : fibs) {
			i++;
			sums[i] = sums[i-1] + fib;
			map.put(fib, i);
		}

		int T = in.nextInt();
		i = 0;
		//System.out.println(fibs.size());
		for(int t= 0; t < T; t++) {
			N = in.nextLong();

			System.out.println(go(N, map.get(fibs.lower(N+1))));
		}

	}

	public static int go(long num, int lastFib) {
		//System.out.printf("num=%d , lastFib=%d\n", num, lastFib);
		if(num == 1 || num == 2)
			return 1;
		if(num == 3)
			return 2;

		long next = sums[lastFib] - num;
		if(next >= num)
			return go(num, lastFib-1) + 1;
		//System.out.println("next " + next);
		//System.out.println("test " + fibs.lower(next+1));
		return go(next, map.get(fibs.lower(next+1)));
	}
}


import java.util.*;
public class r126D {
	static long[] fibNumbers;
	static TreeSet<Long> fibNums;
	static long N;
	static int i;
	static TreeSet<Long> fibs;
	static HashMap<Long, Integer> map;
	static long[] sums;
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		fibNumbers = new long[86];
		fibs = new TreeSet<Long>();
		fibNumbers[0] = 1;
		fibNumbers[1] = 2;
		fibs.add(1l);
		fibs.add(2l);
		i = 0;
		while(true) {
			if(fibNumbers[i]+fibNumbers[i+1] > 1e18)
				break;
			fibNumbers[i+2] = fibNumbers[i+1] + fibNumbers[i];
			fibs.add(fibNumbers[i+2]);
			i++;
		}

		sums = new long[87];
		i = 0;
		map = new HashMap<Long, Integer>();
		for(long fib : fibs) {
			i++;
			sums[i] = sums[i-1] + fib;
			map.put(fib, i);
		}

		int T = in.nextInt();
		i = 0;
		//System.out.println(fibs.size());
		for(int t= 0; t < T; t++) {
			N = in.nextLong();

			System.out.println(go(N, map.get(fibs.lower(N+1))));
		}

	}

	public static int go(long num, int lastFib) {
		//System.out.printf("num=%d , lastFib=%d\n", num, lastFib);
		if(num == 1 || num == 2)
			return 1;
		if(num == 3)
			return 2;

		long next = sums[lastFib] - num;
		if(next == num)
			return go(num, lastFib-1) + 2;
		if(next > num)
			return go(num, lastFib-1) + 1;
		//System.out.println("next " + next);
		//System.out.println("test " + fibs.lower(next+1));
		return go(next, map.get(fibs.lower(next+1)));
	}
}


import java.util.*;
public class r126D {
	static long[] fibNumbers;
	static long N;
	static int i;
	static int[] runZ;
	static int[][] memo;
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		fibNumbers = new long[86];
		fibNumbers[0] = 1;
		fibNumbers[1] = 2;
		i = 0;
		while(true) {
			if(fibNumbers[i]+fibNumbers[i+1] > 1e18)
				break;
			fibNumbers[i+2] = fibNumbers[i+1] + fibNumbers[i];
			i++;
		}

		int T = in.nextInt();
		i = 0;
		//System.out.println(fibs.size());
		for(int t= 0; t < T; t++) {
			N = in.nextLong();
			String start = buildFirst(N);
			runZ = buildArray(start);
			memo = new int[2][runZ.length+1];
			for(int[] mem:memo) Arrays.fill(mem, -1);
			System.out.println(go(0, 0));
		}

	}

	public static int go(int flag, int pos) {
		if(pos == runZ.length)
			return 1;

		if(memo[flag][pos] != -1)
			return memo[flag][pos];

		return memo[flag][pos] = ((runZ[pos]+flag)/2)*go(1, pos+1) + go(0, pos+1);
	}

	public static int[] buildArray(String num) {
		int count = 0;
		for(int i = 0; i < num.length(); i++) {
			if(num.charAt(i) == '1')
				count++;
		}

		int[] res = new int[count];

		int lasti = 0;
		int pos = 0;
		for(int i = 0; i < num.length(); i++) {
			if(num.charAt(num.length()-i-1) == '1') {
				res[pos] = i-lasti;
				lasti = i+1;
				pos++;
			}
		}

		return res;
	}

	public static String buildFirst(long num) {
		char[] res = new char[86];
		for(int i = 85; i >= 0; i--) {
			if(num >= fibNumbers[i]) {
				res[85-i] = '1';
				num -= fibNumbers[i];
			} else {
				res[85-i] = '0';
			}
		}

		return new String(res);
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long LL;

const int maxn=84;
int T;
LL n, fib[maxn+10], ans;

void calc(LL n, int p){
	if (n==0){ans++;return;}
	if (p==0) return;
	if (fib[p]<=n) calc(n-fib[p], p-1);
	if (fib[p+2]>=n) calc(n, p-1);
}

int main(){
	fib[0]=fib[1]=1;
	for (int i=2; i<=maxn; i++) fib[i]=fib[i-1]+fib[i-2];
	for (cin>>T; T; T--){
		cin>>n;
		ans=0;
		int i=maxn;
		for (;fib[i]>n;i--);
		calc(n, i);
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

typedef long long LL;

const int maxn=85;
int T;
LL n, fib[maxn+10], ans, s[maxn+10], f[100][4];
int p[maxn+10];

void calc(LL n, int last){
	memset(p, 0, sizeof(p));
	memset(f, 0, sizeof(f));
	for (int i=last; i>0; i--)
		if (n>=fib[i]) p[i]=1, n-=fib[i];
	for (int i=1; i<=last; i++) s[i]=s[i-1]+(p[i]>0?fib[i]:0);

	f[last][0]=1;
	for (int i=last; i>0; i--){
		if (p[i]){
			f[i-1][0]+=f[i][0]; f[i-1][3]+=f[i][0];
			f[i-1][2]+=f[i][1]; f[i-1][3]+=f[i][2];
		}else{
			f[i-1][0]+=f[i][0]; f[i-1][2]+=f[i][1];
			f[i-1][0]+=f[i][2]; f[i-1][3]+=f[i][2];
			f[i-1][2]+=f[i][3];
		}
	}
	ans=f[0][0];
}

int main(){
	fib[0]=fib[1]=1;
	for (int i=2; i<maxn; i++) fib[i]=fib[i-1]+fib[i-2];
	for (cin>>T; T; T--){
		cin>>n;
		ans=0;
		int i=maxn-1;
		for (;fib[i]>n;i--);
		calc(n, i);
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

typedef long long LL;

const int maxn=90;
int T;
LL n, fib[maxn+10], ans, s[maxn+10], f[100][4];
int p[maxn+10];

void calc(LL n, int last){
	memset(p, 0, sizeof(p));
	memset(f, 0, sizeof(f));
	for (int i=last; i>0; i--)
		if (n>=fib[i]) p[i]=1, n-=fib[i];
	for (int i=1; i<=last; i++) s[i]=s[i-1]+(p[i]>0?fib[i]:0);

	f[last][0]=1;
	for (int i=last; i>0; i--){
		if (p[i]){
			f[i-1][0]+=f[i][0]; f[i-1][3]+=f[i][0];
			f[i-1][2]+=f[i][1]; f[i-1][3]+=f[i][2];
		}else{
			f[i-1][0]+=f[i][0]; f[i-1][2]+=f[i][1];
			f[i-1][0]+=f[i][2]; f[i-1][3]+=f[i][2];
			f[i-1][2]+=f[i][3];
		}
	}
	ans=f[0][0];
}

int main(){
	fib[0]=fib[1]=1;
	for (int i=2; i<maxn; i++) fib[i]=fib[i-1]+fib[i-2];
	for (cin>>T; T; T--){
		cin>>n;
		ans=0;
		int i=maxn-1;
		for (;fib[i]>n;i--);
		calc(n, i);
		cout<<ans<<endl;
	}
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<assert.h>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>

using namespace std;

int cs;
int n;
long long fib[100];
int vis[100][3][3];
long long mem[100][3][3];

int sig[100];

void make(long long num)
{
    int i;
    n=0;
    for(i=83;i>=0;i--)
    {
        if(fib[i]<=num)
        {
            n=max(n,i);
            num-=fib[i];
            sig[i]=1;
        }
        else sig[i]=0;
    }
}

// 2 1 gese morse
// >2 gese ga
long long get(int pos,int now,int pore)
{
    if(pos==-1)
    {
        if(now || pore) return 0;
        else return 1;
    }

    long long ret=0;
    if(vis[pos][now][pore]==cs) return mem[pos][now][pore];
    now+=sig[pos];

    if(now>2) return 0;
    if(now>=2 && pore>=1) return 0;

    if(now==2)
    {
        ret+=get(pos-1,pore+1,1);
    }
    else if(now==1)
    {
        ret+=get(pos-1,pore,0);
        ret+=get(pos-1,pore+1,1);
    }
    else
    {
        ret+=get(pos-1,pore,0);
    }

    now-=sig[pos];

    vis[pos][now][pore]=cs;
    mem[pos][now][pore]=ret;
}

int main()
{

    //freopen("in.txt","r",stdin);
    int T,i;
    long long ans,num;
    scanf("%d",&T);

    fib[0]=1;
    fib[1]=2;

    for(i=2;i<=86;i++)
        fib[i]=fib[i-1]+fib[i-2];

    for(cs=1;cs<=T;cs++)
    {
        scanf("%I64d",&num);

        make(num);
        ans=get(n,0,0);

        printf("%I64d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<assert.h>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>

using namespace std;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define EPS 1e-9

int cs;
int n;
long long fib[100];
int vis[100][3][3];
long long mem[100][3][3];

int sig[100];

void make(long long num)
{
    int i;
    n=0;
    for(i=83;i>=0;i--)
    {
        if(fib[i]<=num)
        {
            n=max(n,i);
            num-=fib[i];
            sig[i]=1;
        }
        else sig[i]=0;
    }
}

// 2 1 gese morse
// >2 gese ga
long long get(int pos,int now,int pore)
{
    if(pos==-1)
    {
        if(now || pore) return 0;
        else return 1;
    }

    long long ret=0;
    if(vis[pos][now][pore]==cs) return mem[pos][now][pore];
    now+=sig[pos];

    if(now>2) return 0;
    if(now>=2 && pore>=1) return 0;

    if(now==2)
    {
        ret+=get(pos-1,pore+1,1);
    }
    else if(now==1)
    {
        ret+=get(pos-1,pore,0);
        ret+=get(pos-1,pore+1,1);
    }
    else
    {
        ret+=get(pos-1,pore,0);
    }

    now-=sig[pos];

    vis[pos][now][pore]=cs;
    mem[pos][now][pore]=ret;
}

int main()
{

    //freopen("in.txt","r",stdin);
    int T,i;
    long long ans,num;
    scanf("%d",&T);

    fib[0]=1;
    fib[1]=2;

    for(i=2;i<=86;i++)
        fib[i]=fib[i-1]+fib[i-2];

    for(cs=1;cs<=T;cs++)
    {
        scanf("%I64d",&num);

        make(num);
        ans=get(n,0,0);

        printf("%I64d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<assert.h>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>

using namespace std;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define EPS 1e-9

int cs;
int n;
long long fib[100];
int vis[100][3][3];
long long mem[100][3][3];

int sig[100];

void make(long long num)
{
    int i;
    n=0;
    for(i=86;i>=0;i--)
    {
        if(fib[i]<=num)
        {
            n=max(n,i);
            num-=fib[i];
            sig[i]=1;
        }
        else sig[i]=0;
    }
}

// 2 1 gese morse
// >2 gese ga
long long get(int pos,int now,int pore)
{
    if(pos==-1)
    {
        if(now || pore) return 0;
        else return 1;
    }

    long long ret=0;
    if(vis[pos][now][pore]==cs) return mem[pos][now][pore];
    now+=sig[pos];

    if(now>2) return 0;
    if(now>=2 && pore>=1) return 0;

    if(now==2)
    {
        ret+=get(pos-1,pore+1,1);
    }
    else if(now==1)
    {
        ret+=get(pos-1,pore,0);
        ret+=get(pos-1,pore+1,1);
    }
    else
    {
        ret+=get(pos-1,pore,0);
    }

    now-=sig[pos];

    vis[pos][now][pore]=cs;
    mem[pos][now][pore]=ret;
}

int main()
{

    //freopen("in.txt","r",stdin);
    int T,i;
    long long ans,num;
    scanf("%d",&T);

    fib[0]=1;
    fib[1]=2;

    for(i=2;i<=86;i++)
    {
        fib[i]=fib[i-1]+fib[i-2];
   //     cout<<fib[i]<<endl;
    }

    for(cs=1;cs<=T;cs++)
    {
        scanf("%I64d",&num);

        make(num);
        ans=get(n,0,0);

        printf("%I64d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#define N 10000
#define INF 0x6f6f6f6f
#define debug(a) cout<<#a<<' '<<a<<endl;
typedef long long LL;
using namespace std;
LL fib[100];
void init()
{
    fib[1]=1;
    fib[2]=2;
    for(int i=3;i<=88;i++)
        fib[i]=fib[i-1]+fib[i-2];
}

int f[100];
LL dp[100][2];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif

    init();
    int T;
    scanf("%d",&T);
    LL x;
    while(T--)
    {
        cin>>x;
        int l=1;
        LL t=x;
        for(int i=88;i>=1;i--)
        {
            if(t>=fib[i])
            {
                t-=fib[i];
                f[l++]=i;
            }
            if(t==0)break;
        }
        if(t!=0)
        {
            printf("0\n");
            continue;
        }
        memset(dp,0,sizeof(dp));
        dp[l-1][1]=1;
        dp[l-1][0]=(f[l-1]-1)/2;
        for(int i=l-2;i>=1;i--)
        {
            dp[i][1]=dp[i+1][1]+dp[i+1][0];
            dp[i][0]=dp[i+1][1]*(f[i]-f[i+1]-1)/2;
            dp[i][0]+=dp[i+1][0]*(f[i]-f[i-1])/2;
        }
        cout<<dp[1][0]+dp[1][1]<<endl;
    }
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#define N 10000
#define INF 0x6f6f6f6f
#define debug(a) cout<<#a<<' '<<a<<endl;
typedef long long LL;
using namespace std;
LL fib[100];
void init()
{
    fib[1]=1;
    fib[2]=2;
    for(int i=3;i<=88;i++)
        fib[i]=fib[i-1]+fib[i-2];
}

int f[100];
LL dp[100][2];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif

    init();
    int T;
    scanf("%d",&T);
    LL x;
    while(T--)
    {
        cin>>x;
        int l=1;
        LL t=x;
        for(int i=88;i>=1;i--)
        {
            if(t>=fib[i])
            {
                t-=fib[i];
                f[l++]=i;
            }
            if(t==0)break;
        }
        if(t!=0)
        {
            printf("0\n");
            continue;
        }
        memset(dp,0,sizeof(dp));
        dp[l-1][1]=1;
        dp[l-1][0]=(f[l-1]-1)/2;
        for(int i=l-2;i>=1;i--)
        {
            dp[i][1]=dp[i+1][1]+dp[i+1][0];

            dp[i][0]+=dp[i+1][1]*((f[i]-f[i+1]-1)/2);

            dp[i][0]+=dp[i+1][0]*((f[i]-f[i+1])/2);
            //cout<<i<<" "<<dp[i][0]<<" "<<f[i]<<endl;
        }
        cout<<dp[1][0]+dp[1][1]<<endl;
    }
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#define N 10000
#define INF 0x6f6f6f6f
#define debug(a) cout<<#a<<' '<<a<<endl;
typedef long long LL;
using namespace std;
LL fib[100];
void init()
{
    fib[1]=1;
    fib[2]=2;
    for(int i=3;i<=88;i++)
        fib[i]=fib[i-1]+fib[i-2];
}

int f[100];
LL dp[100][2];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif

    init();
    int T;
    scanf("%d",&T);
    LL x;
    while(T--)
    {
        cin>>x;
        int l=1;
        LL t=x;
        for(int i=88;i>=1;i--)
        {
            if(t>=fib[i])
            {
                t-=fib[i];
                f[l++]=i;
            }
            if(t==0)break;
        }
        if(t!=0)
        {
            printf("0\n");
            continue;
        }
        memset(dp,0,sizeof(dp));
        dp[l-1][1]=1;
        dp[l-1][0]=(f[l-1]-1)/2;
        for(int i=l-2;i>=1;i--)
        {
            dp[i][1]=dp[i+1][1]+dp[i+1][0];
            dp[i][0]=dp[i+1][1]*(f[i]-f[i+1]-1)/2;
            dp[i][0]+=dp[i+1][0]*(f[i]-f[i+1])/2;
        }
        cout<<dp[1][0]+dp[1][1]<<endl;
    }
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#define N 10000
#define INF 0x6f6f6f6f
#define debug(a) cout<<#a<<' '<<a<<endl;
typedef long long LL;
using namespace std;
LL fib[100];
void init()
{
    fib[1]=1;
    fib[2]=2;
    for(int i=3;i<=88;i++)
        fib[i]=fib[i-1]+fib[i-2];
}

int f[100];
LL dp[100][2];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif

    init();
    int T;
    scanf("%d",&T);
    LL x;
    while(T--)
    {
        cin>>x;
        int l=1;
        LL t=x;
        for(int i=88;i>=1;i--)
        {
            if(t>=fib[i])
            {
                t-=fib[i];
                f[l++]=i;
            }
            if(t==0)break;
        }
        if(t!=0)
        {
            printf("0\n");
            continue;
        }
        memset(dp,0,sizeof(dp));
        dp[l-1][1]=1;
        dp[l-1][0]=(f[l-1]-1)/2;
        for(int i=l-2;i>=1;i--)
        {
            dp[i][1]=dp[i+1][1]+dp[i+1][0];
            dp[i][1]=dp[i+1][1]*(f[i]-f[i+1]-1)/2;
            dp[i][1]+=dp[i+1][0]*(f[i]-f[i-1])/2;
        }
        cout<<dp[1][0]+dp[1][1]<<endl;
    }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include <memory.h>
#define CLR(x) memset(x,0,sizeof(x))
#define INF 1<<30
typedef long long ll;
using namespace std;
ll f[90];
int b[90],a[90];
ll dp[90][2];

void init()
{
    f[1]=1; f[2]=2;
    for (int i=3;i<=88;i++)
        f[i]=f[i-1]+f[i-2];
}

int main()
{
    int t,cnt;
    scanf("%d",&t);
    init();
    for (int i=1;i<=t;i++)
    {
        ll n;
        scanf("%I64d",&n);
        cnt=0;
        for (int i=88;i>=1;i--)
        {
           if(f[i]<=n)
            {
               n-=f[i];
               a[++cnt]=i;
            }
        }
        for (int i=1;i<=cnt;i++)
            b[i]=a[cnt-i+1];
        CLR(dp);
        dp[1][1]=1;
        dp[1][0]=(b[1]-1)/2;
        for (int i=2;i<=cnt;i++)
        {
            dp[i][1]=dp[i-1][0]+dp[i-1][1];
            dp[i][0]=(b[i]-b[i-1]-1)/2*dp[i-1][1]+(b[i]-b[i-1])/2*dp[i-1][0];
        }
        printf("%I64d\n",dp[cnt][1]+dp[cnt][0]);
    }

}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include <memory.h>
#define CLR(x) memset(x,0,sizeof(x))
#define INF 1<<30
typedef long long ll;
using namespace std;
ll f[90];
int b[90],a[90];
ll dp[90][2];

void init()
{
    f[1]=1; f[2]=2;
    for (int i=3;i<=88;i++)
        f[i]=f[i-1]+f[i-2];
}

int main()
{
    int t,cnt;
    scanf("%d",&t);
    init();
    for (int i=1;i<=t;i++)
    {
        int n;
        scanf("%d",&n);
        cnt=0;
        for (int i=88;i>=1;i--)
        {
           if(f[i]<=n)
            {
               n-=f[i];
               a[++cnt]=i;
            }
        }
        for (int i=1;i<=cnt;i++)
            b[i]=a[cnt-i+1];
        CLR(dp);
        dp[1][1]=1;
        dp[1][0]=(b[1]-1)/2;
        for (int i=2;i<=cnt;i++)
        {
            dp[i][1]=dp[i-1][0]+dp[i-1][1];
            dp[i][0]=(b[i]-b[i-1]-1)/2*dp[i-1][1]+(b[i]-b[i-1])/2*dp[i-1][0];
        }
        printf("%I64d\n",dp[cnt][1]+dp[cnt][0]);
    }

}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const int N = 800005;
const ll INF = (ll)1e18;
ll f[1000];
ll gp[1000];
int dp[N][87];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	gp[1] = gp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		gp[i] = gp[i + 1] = gp[i - 2] + 1;
	}
	clr(dp, -1);
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

int get(ll x, int big) {
	if (x < N && ~dp[x][big]) {
		return dp[x][big];
	}
	int pos = find(x);
	if (pos != -1) {
		if (x < N) dp[x][big] = gp[pos];
		return gp[pos];
	} else {
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		int ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= f[big]) break;
			ll fst = x - f[i];
			ret += get(fst, i);
			if (fst == f[i]) {
				ret--;
			}
		}
		if (x < N) dp[x][big] = ret;
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, 86) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const int N = 500005;
const ll INF = (ll)1e18;
ll f[1000];
ll gp[1000];
int dp[N][87];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	gp[1] = gp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		gp[i] = gp[i + 1] = gp[i - 2] + 1;
	}
	clr(dp, -1);
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

int get(ll x, int big) {
	if (x < N && ~dp[x][big]) {
		return dp[x][big];
	}
	int pos = find(x);
	if (pos != -1) {
		if (x < N) dp[x][big] = gp[pos];
		return gp[pos];
	} else {
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		int ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= f[big]) break;
			ll fst = x - f[i];
			ret += get(fst, i);
			if (fst == f[i]) {
				ret--;
			}
		}
		if (x < N) dp[x][big] = ret;
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, 86) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const int N = 1000005;
const ll INF = (ll)1e18;
ll f[1000];
ll gp[1000];
short dp[N][87];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	gp[1] = gp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		gp[i] = gp[i + 1] = gp[i - 2] + 1;
	}
	clr(dp, -1);
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

short get(ll x, int big) {
	if (x < N && ~dp[x][big]) {
		return dp[x][big];
	}
	int pos = find(x);
	if (pos != -1) {
		if (x < N) dp[x][big] = gp[pos];
		return gp[pos];
	} else {
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		int ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= f[big]) break;
			ll fst = x - f[i];
			ret += get(fst, i);
			if (fst == f[i]) {
				ret--;
			}
		}
		if (x < N) dp[x][big] = ret;
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, 86) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const int N = 400005;
const ll INF = (ll)1e18;
ll f[1000];
ll gp[1000];
int dp[N][87];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	gp[1] = gp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		gp[i] = gp[i + 1] = gp[i - 2] + 1;
	}
	clr(dp, -1);
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

int get(ll x, int big) {
	if (x < N && ~dp[x][big]) {
		return dp[x][big];
	}
	int pos = find(x);
	if (pos != -1) {
		if (x < N) dp[x][big] = gp[pos];
		return gp[pos];
	} else {
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		int ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= f[big]) break;
			ll fst = x - f[i];
			ret += get(fst, i);
			if (fst == f[i]) {
				ret--;
			}
		}
		if (x < N) dp[x][big] = ret;
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, 86) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const int N = 100005;
const ll INF = (ll)1e18;
ll f[1000];
ll gp[1000];
int dp[N][87];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	gp[1] = gp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		gp[i] = gp[i + 1] = gp[i - 2] + 1;
	}
	clr(dp, -1);
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

int get(ll x, int big) {
	if (x < N && ~dp[x][big]) {
		return dp[x][big];
	}
	int pos = find(x);
	if (pos != -1) {
		if (x < N) dp[x][big] = gp[pos];
		return gp[pos];
	} else {
		ll tmp = (x + 1) / 2;
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		int ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= f[big]) break;
			ll fst = x - f[i];
			ret += get(fst, i);
			if (fst == f[i]) {
				ret--;
			}
		}
		if (x < N) dp[x][big] = ret;
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, 86) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

ll f[100];
int s[100];
ll dp[100][2];

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	f[0] = f[1] = 1;
	for (int i = 2; i < 100; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		int cnt = 0;
		for (int i = 90; i >= 1; i--) {
			if (n >= f[i]) {
				n -= f[i];
				s[++cnt] = i;
			}
		}
		reverse(s + 1, s + cnt + 1);
		dp[0][0] = 1;
		dp[0][1] = 0;
		for (int i = 1; i <= cnt; i++) {
			dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][1] = dp[i - 1][0] * (s[i] - s[i - 1] - 1) / 2 +
					   dp[i - 1][1] * (s[i] - s[i - 1]) / 2;
		}
		cout << dp[cnt][0] + dp[cnt][1] << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const int N = 200005;
const ll INF = (ll)1e18;
ll f[1000];
ll gp[1000];
int dp[N][87];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	gp[1] = gp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		gp[i] = gp[i + 1] = gp[i - 2] + 1;
	}
	clr(dp, -1);
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

int get(ll x, int big) {
	if (x < N && ~dp[x][big]) {
		return dp[x][big];
	}
	int pos = find(x);
	if (pos != -1) {
		if (x < N) dp[x][big] = gp[pos];
		return gp[pos];
	} else {
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		int ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= f[big]) break;
			ll fst = x - f[i];
			ret += get(fst, i);
			if (fst == f[i]) {
				ret--;
			}
		}
		if (x < N) dp[x][big] = ret;
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, 86) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const int N = 10005;
const ll INF = (ll)1e18;
ll f[1000];
ll gp[1000];
ll dp[N][87];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	gp[1] = gp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		gp[i] = gp[i + 1] = gp[i - 2] + 1;
	}
	clr(dp, -1);
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

ll get(ll x, int big) {
	if (x < N && ~dp[x][big]) {
		return dp[x][big];
	}
	int pos = find(x);
	if (pos != -1) {
		if (x < N) dp[x][big] = gp[pos];
		return gp[pos];
	} else {
		ll tmp = (x + 1) / 2;
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		ll ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= f[big]) break;
			ll fst = x - f[i];
			ret += get(fst, i);
			if (fst == f[i]) {
				ret--;
			}
		}
		if (x < N) dp[x][big] = ret;
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, 86) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const ll INF = (ll)1e18;
ll f[1000];
int dp[1000];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	dp[1] = dp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		dp[i] = dp[i + 1] = dp[i - 2] + 1;
	}
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

ll get(ll x) {
	if (x <= 0) return 0;
	int pos = find(x);
	if (pos != -1) {
		return dp[pos];
	} else {
		ll tmp = (x + 1) / 2;
		int p1 = lower_bound(f, f + 87, tmp) - f;
		int p2 = upper_bound(f, f + 87, x) - f;
		ll ret = 0;
		for (int i = p1; i < p2; i++) {
			ll fst = x - f[i];
			ret += get(fst);
			if (fst == f[i]) {
				ret--;
			}
		}
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const int N = 700005;
const ll INF = (ll)1e18;
ll f[1000];
ll gp[1000];
int dp[N][87];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	gp[1] = gp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		gp[i] = gp[i + 1] = gp[i - 2] + 1;
	}
	clr(dp, -1);
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

int get(ll x, int big) {
	if (x < N && ~dp[x][big]) {
		return dp[x][big];
	}
	int pos = find(x);
	if (pos != -1) {
		if (x < N) dp[x][big] = gp[pos];
		return gp[pos];
	} else {
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		int ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= f[big]) break;
			ll fst = x - f[i];
			ret += get(fst, i);
			if (fst == f[i]) {
				ret--;
			}
		}
		if (x < N) dp[x][big] = ret;
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, 86) << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

ll f[100];
int s[100];
ll dp[100][2];

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	f[0] = f[1] = 1;
	for (int i = 2; i < 100; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		int cnt = 0;
		for (int i = 90; i >= 1; i--) {
			if (n >= f[i]) {
				n -= f[i];
				s[++cnt] = i;
			}
		}
		reverse(s + 1, s + cnt + 1);
		dp[0][0] = 1;
		dp[0][1] = 0;
		for (int i = 1; i <= cnt; i++) {
			dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][1] = dp[i - 1][0] * ((s[i] - s[i - 1] - 1) / 2) +
					   dp[i - 1][1] * ((s[i] - s[i - 1]) / 2);
		}
		cout << dp[cnt][0] + dp[cnt][1] << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define clr(a, x) memset(a, x, sizeof(a))

const ll INF = (ll)1e18;
ll f[1000];
int dp[1000];

void init() {
	f[1] = 1;
	f[2] = 2;
	for (int i = 3; i <= 86; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	dp[1] = dp[2] = 1;
	for (int i = 3; i <= 86; i += 2) {
		dp[i] = dp[i + 1] = dp[i - 2] + 1;
	}
}

ll find(ll x) {
	int pos = lower_bound(f, f + 87, x) - f;
	if (pos == 87 || f[pos] != x) return -1;
	return pos;
}

ll get(ll x, ll big) {
	if (x <= 0) return 0;
	int pos = find(x);
	if (pos != -1) {
		return dp[pos];
	} else {
		ll tmp = (x + 1) / 2;
		int p1 = max(1, upper_bound(f, f + 87, x / 3) - f);
		int p2 = upper_bound(f, f + 87, x) - f;
		ll ret = 0;
		for (int i = p1; i < p2; i++) {
			if (f[i] >= big) break;
			ll fst = x - f[i];
			ret += get(fst, f[i]);
			if (fst == f[i]) {
				ret--;
			}
		}
		return ret;
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	init();

	int cas;
	cin >> cas;
	while (cas--) {
		ll n;
		cin >> n;
		cout << get(n, INF) << endl;
	}

	return 0;
}


#include <cstdio>
#include <map>

using namespace std;

const int maxn = 220;
const long long maxnum = 1000000000000000000LL;
int tr, tot;
long long n, f[maxn], s[maxn];

map<pair<long long, int>, int> G;

int slove(long long k, int h)
{
	if (k == 0)
	        return 1;
	pair<long long, int> p = make_pair(k, h);
	if (G.find(p) != G.end())
	        return G[p];
	int res = 0;
	for (int i = h; i > 0 && s[i] >= k; i--)
	        if (f[i] <= k)
	                res += slove(k - f[i], i - 1);
	return G[p] = res;
}

int main()
{
	f[0] = 1, f[1] = 1, s[1] = 1;
	for (int i = 2; f[i - 1] + f[i - 2] <= maxnum; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
		s[i] = s[i - 1] + f[i];
		tot = i;
	}
	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		scanf("%I64d", &n);
		printf("%d\n", slove(n, tot));
	}

	return 0;
}


#include <cstdio>
#include <map>

using namespace std;

const int maxn = 220;
const long long maxnum = 1000000000000000000LL;
int tr, tot;
long long n, f[maxn], s[maxn];

map<pair<long long, int>, int> G;

int slove(long long k, int h)
{
	if (k == 0)
	        return 1;
	if (f[h] > k)
	        return slove(k, h - 1);
	pair<long long, int> p = make_pair(k, h);
	if (G.find(p) != G.end())
	        return G[p];
	int res = 0;
	for (int i = h; i > 0 && s[i] >= k; i--)
	        res += slove(k - f[i], i - 1);
	return G[p] = res;
}

int main()
{
	f[0] = 1, f[1] = 1, s[1] = 1;
	for (int i = 2; f[i - 1] + f[i - 2] <= maxnum; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
		s[i] = s[i - 1] + f[i];
		tot = i;
	}
	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		scanf("%I64d", &n);
		printf("%d\n", slove(n, tot));
	}

	return 0;
}


#include <cstdio>
#include <cstring>

using namespace std;

int tr, num, p[90];
long long f[90], g[90], fib[90];

int main()
{
	fib[0] = 1, fib[1] = 1;
	for (int i = 2; i < 88; i++)
		fib[i] = fib[i - 1] + fib[i - 2];
	int maxnum = 87;

	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		memset(p, 0, sizeof p);
		scanf("%d", &num);
		for (int t = maxnum; t > 0; t--)
		    if (num >= fib[t])
		    {
				//printf("%d\n", t);
				p[t] = 1;
				num -= fib[t];
			}
		g[1] = f[1] = 1;
		int flag = -1;
		for (int i = 2; i <= maxnum; i++)
		{
			g[i] = f[i] = f[i - 1];
			if (p[i] == 1 && flag > 0)
				f[i] += g[flag];
		    if (p[i] == 0 && p[i - 1] == 0)
		    {
				if (flag > 0)
				    g[i] += g[flag];
		        flag = i - 1;
			}
		}
		printf("%I64d\n", f[maxnum]);

	}

	return 0;
}


#include <cstdio>

using namespace std;

const int maxn = 220;
const long long maxnum = 1000000000000000000LL;
int tr, tot, n;
long long f[maxn], s[maxn];

int slove(long long k, int h)
{
	if (k == 0)
	        return 1;
	int res = 0;
	for (int i = h; i > 0 && s[i] >= k; i--)
	        if (f[i] <= k)
	                res += slove(k - f[i], i - 1);
	return res;
}

int main()
{
	f[0] = 1, f[1] = 1, s[1] = 1;
	for (int i = 2; f[i - 1] + f[i - 2] <= maxnum; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
		s[i] = s[i - 1] + f[i];
		tot = i;
	}
	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		scanf("%I64d", &n);
		printf("%d\n", slove(n, tot));
	}

	return 0;
}