N = gets.to_i def f(n) return '{}' if n == 0 s = [] n.bit_length.times do |i| next if n[i] == 0 s << f(i) end '{' + s.join(',') + '}' end puts f(N)