K = gets.to_i q = [[?A, ?E], [?B], [?C], [?D]] K.times do |i| q[(i + 1) % 4] << q[i % 4].shift end puts q.map(&:join)