class SeatOrganizer
  def initialize(number_of_seats:)
    @records = {}
    @number_of_seats = number_of_seats
    @open_seats = (0...@number_of_seats).to_a.map {|c| [c, 0]}.to_h

    @cancel_seats = (0...number_of_seats).to_a.map {|c| [c, []]}.to_h
    (0...number_of_seats).each do |seat|
      @cancel_seats[seat] << (seat-1)%number_of_seats
      @cancel_seats[seat] << (seat+1)%number_of_seats
      @cancel_seats[seat] << (seat + number_of_seats / 2) % number_of_seats if number_of_seats % 2 == 0
    end
  end

  def calc_possible_ways
    return 0 if @number_of_seats < 17

    @open_seats[0] += 1
    @cancel_seats[0].each do |seat|
      @open_seats[seat] += 1
    end

    organize_seats(princes: 7) * @number_of_seats
  end

  def set_seat(position:, option:)
    (0..position).each do |seat|
      @open_seats[seat] += option
    end
    @cancel_seats[position].each do |seat|
      @open_seats[seat] += option
    end
  end

  def organize_seats(princes:)
    efes = @open_seats.values.map{|v| v == 0 ? 't':'f'}.join
    key = "#{princes}#{efes}"

    return @records[key] if @records.key? key

    return @open_seats.count {|_, value| value == 0} if princes == 1

    total = 0

    (0...@number_of_seats).each do |seat|
      next unless @open_seats[seat] == 0
      set_seat(position: seat, option: 1)
      total += princes*organize_seats(princes: princes-1)
      set_seat(position: seat, option: -1)
    end

    @records[key] = total
    total
  end
end


chairs = gets.to_i
while chairs > 0
  organizer = SeatOrganizer.new(number_of_seats: chairs)
  puts organizer.calc_possible_ways
  chairs = gets.to_i
end