begin
  games = ARGV.map {|s| Integer(s)}
rescue => err
  $stderr.puts err.inspect
  $stderr.puts 
  abort
end
games.empty? and games = [rand(32000)]


orig_deck = %w{A 2 3 4 5 6 7 8 9 T J Q K}.product(%w{C D H S}).map(&:join)

games.each do |seed|
  deck = orig_deck.dup

  
  
  state = seed
  52.downto(2) do |len|
    state = ((214013 * state) + 2531011) & 0x7fff_ffff
    index = (state >> 16) % len
    last = len - 1
    deck[index], deck[last] = deck[last], deck[index]
  end

  deck.reverse!  

  
  puts 
  deck.each_slice(8) {|row| puts  + row.join()}
  puts
end