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. 2.9 logistic回归中的梯度下降法(非常重要,一定要重点理解)

    怎么样计算偏导数来实现logistic回归的梯度下降法 它的核心关键点是其中的几个重要公式用来实现logistic回归的梯度下降法 接下来开始学习logistic回归的梯度下降法 logistic回归 ...

  2. Selenium 页面加载慢

    Selenium 页面加载慢 问题描述: 使用Selenium获取网页,发现webdriver.get方法会阻塞直到网页全部加载完成,官方提供的三种wait方法仅对网页的ajax有比较明显的效果.对于 ...

  3. Python基础-4 运算符

    运算符 运算符:以1 + 2为例,1和2被称为操作数,"+" 称为运算符. Python语言支持以下类型的运算符: 算术运算符 比较(关系)运算符 赋值运算符 逻辑运算符 位运算符 ...

  4. 《Java Spring框架》Spring IOC 源码分析

    1.下载源码 源码部署:https://www.cnblogs.com/jssj/p/11631881.html 并不强求,最好是有源码(方便理解和查问题). 2. 创建子项目 Spring项目中创建 ...

  5. JS html页面

    js窗口置顶 if (window != top) top.location.href = location.href; js打开新窗口 js window.open()弹出窗口参数说明及居中设置 f ...

  6. 捣鼓FileZilla

    今天突然对ftp服务器感兴趣,于是随意打了一个ftp词条,发现了FZ官网,好奇点进去下载了之后,捣鼓了一会.于是,也写一个小教程记录一下吧,害怕自己以后忘记怎么弄的了. 首先需要用到两个,一个是FZ ...

  7. 轉:StackOverflow2016最新架构探秘

    轉載:http://www.infoq.com/cn/news/2016/03/Stack-Overflow-architecture-insi?utm_source=tuicool&utm_ ...

  8. js 字符串 常用处理方式(检索、截取、拼接、批量替换)

    // 检索(字符串中判断是否包含某个字符) 字符串.search('检索的内容');// 返回-1,不包含: 返回非-1,包含 字符串.indexOf("待判断的内容"); // ...

  9. web应用基础架构

    1.web中间件 中间件是一类连接软件组件和应用的计算机软件,它包括一组服务.以便运行在一台或多台服务器上的多个软件通过网络进行交互.该技术所提供的互操作性,推动了一致分布式体系架构的演进,该架构通常 ...

  10. ROS学习笔记8-rqt_console和roslaunch

    本教程来自于:http://wiki.ros.org/ROS/Tutorials/UsingRqtconsoleRoslaunch rqt_console 和 rqt_logger_level 是ro ...