output_description: Print the plural form of the given Taknese word.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: n, x, m = map(int, input().split())
  a = x
  s = 0
  h = []
  h.append(a)
  i = 0
  fl = 0
  while i < n:
      s += a
      a = (a * a) % m
      if a == 0:
          break
      i += 1
      if fl == 0 and a in h:
          fl = 1
          po = h.index(a)
          ss = 0
          for j in range(po):
              ss += h[j]
          s2 = s - ss
          f = (n - po) // (i - po)
          s2 *= f
          s = s2 + ss
          i2 = i - po
          i2 *= f
          i = i2 + po
      else:
          h.append(a)
  print(s)
  
problem_description: Statement
  
  In the Kingdom of AtCoder, people use a language called Taknese, which uses
  lowercase English letters.
  
  In Taknese, the plural form of a noun is spelled based on the following rules:
  
    * If a noun's singular form does not end with `s`, append `s` to the end of the singular form.
    * If a noun's singular form ends with `s`, append `es` to the end of the singular form.
  
  You are given the singular form S of a Taknese noun. Output its plural form.
samples: [{"input": "apple", "output": "apples\n    \n\n`apple` ends with `e`, so its plural form is `apples`.\n\n* * *"}, {"input": "bus", "output": "buses\n    \n\n`bus` ends with `s`, so its plural form is `buses`.\n\n* * *"}, {"input": "box", "output": "boxs"}]