A positive integer aa is given. Baron Munchausen claims that he knows such a positive integer nn that if one multiplies nn by aa, the sum of its digits decreases aa times. In other words, S(an)=S(n)/aS(an)=S(n)/a, where S(x)S(x) denotes the sum of digits of the number xx.

Find out if what Baron told can be true.

Input

The only line contains a single integer aa (2≤a≤1032≤a≤103).

Output

If there is no such number nn, print −1−1.

Otherwise print any appropriate positive integer nn. Your number must not consist of more than 5⋅1055⋅105 digits. We can show that under given constraints either there is no answer, or there is an answer no longer than 5⋅1055⋅105 digits.

Examples

Input
2
Output
6
Input
3
Output
6669
Input
10
Output
-1

题解都不懂的大坑

Day8 - E - The very same Munchhausen CodeForces - 1120E的更多相关文章

  1. Day8 - C - Another Problem on Strings CodeForces - 165C

    A string is binary, if it consists only of characters "0" and "1". String v is a ...

  2. Day8 - D - Multiplication Table CodeForces - 448D

    Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the mu ...

  3. Day8 - B - Non-Secret Cypher CodeForces - 190D

    Berland starts to seize the initiative on the war with Flatland. To drive the enemy from their nativ ...

  4. Day8 - A - Points on Line CodeForces - 251A

    Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. N ...

  5. Codeforces Round #539&#542&#543&#545 (Div. 1) 简要题解

    Codeforces Round #539 (Div. 1) A. Sasha and a Bit of Relax description 给一个序列\(a_i\),求有多少长度为偶数的区间\([l ...

  6. [codeforces] 暑期训练之打卡题(一)

    每个标题都做了题目原网址的超链接 Day1<Vanya and Lanterns> 题意: 一条长度为 l 的街道,在这条街道上放置了n个相同的灯,街道一端位置记为0,每个灯的位置在ai处 ...

  7. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  8. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  9. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

随机推荐

  1. @implementer,抽象类,接口

    @implementer,抽象类,接口 1.      implementer 在看twisted源码时,经常出现@implementer(IReactorFDSet) 它来自zope.interfa ...

  2. Python学习第十四课——面向对象基本思想part1

    面向对象的基本思想 # 写法1 person1 = { 'name': 'hanhan', ', 'sex': '男' } def xue_xi(person): print('%s在学习' % pe ...

  3. Spark教程——(7)编写spark-sql程序读取HBase定时生成报表

    plugin划红线报错: maven-scala-plugin maven-shade-plugin 查找Maven仓库,发现一个没有jar包,一个jar包无法解压缩打开,删除Maven中坏的jar包 ...

  4. docker的私有化仓库harbor搭建

    目前比较流行的docker私有化仓库是harbor,harbor是一个github开源的项目,直接在github上搜索即可,下载地址:https://github.com/goharbor/harbo ...

  5. 聚合数据实名认证接口-java方法

    只需要填入购买的APPKEY,然后直接调用方法JuheDemo.info(user_name, anchor_card);传入姓名和身份证号,根据获取的返回参数进行拆分,如res=1说明正确. //进 ...

  6. linux命令系列-mv(移动-重命名)

    #常用命令选项 默认覆盖 -n 不覆盖 -i 交互 -f 不交互直接覆盖 -u 只移动新的文件 -v 显示详细信息 #移动覆盖3个文件到/tmp目录 mv a.txt b.txt c.txt /tmp ...

  7. Java实现图片内容无损任意角度旋转

    转自:http://blog.csdn.net/heliang7/article/details/7309394 主要问题是如何在图片做旋转后计算出新图片的长宽. 在java 2d和基本math库的帮 ...

  8. No qualifying bean of type 'org.springframework.ui.Model' available

    原因:@Autowired 下面没有注入类

  9. EMIS快速开发平台 - 微服务版技术选型

    http://demo.zuoyour.com/system/login EMIS快速开发平台 - 微服务版技术选型 开发框架:Spring Boot 2.1.3.RELEASE 微服务:Spring ...

  10. 一、jsp和Servlet基础理论及jstl和EL表达式用法

    1.题外话:使用JSP有近一年半的时间了,但是开发量不大.昨天部门突然让做个读取EXCLE文件,然后在前台页面进行展示.并通过点击查看按钮可以对每条明细记录进行跳转后进行详情查看,并按照页面原型进行页 ...