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. 去重sort|uniq -d

    #!/bin/bash ############################################################### #Author :Bing # #Create ...

  2. .net使用rabbitmq安装操作

    自己在windows安装rabbitmq时,遇到了很多坑,最恶心的就是版本不匹配的问题,所以自己写了一篇总结,本文章安装的Erlang为8.2,rabbitmq为3.5.6 1 安装rabbitmq, ...

  3. A股上市公司财报披露时间

    一.上市公司年报披露时间:每年1月1日——4月30日. 二.上市公司中年报披露时间:每年7月1日——8月30日. 三.上市公司季报披露时间: 1季报:每年4月1日——4月30日. 2季报(中报):每年 ...

  4. 【原】postman设置环境变量和全局变量

    一:设置环境变量 1. postman通过变换环境变量来快速变换环境地址. 2. 现可以将localhost:80信息添加至环境 3. 点击确定后,在首页可看到已添加的环境变量信息及设置的变量信息: ...

  5. 【PAT甲级】1023 Have Fun with Numbers (20 分)

    题意: 输入一个不超过20位的正整数,问乘2以后是否和之前的数组排列相同(数字种类和出现的个数不变),输出Yes或No,并输出乘2后的数字. AAAAAccepted code: #define HA ...

  6. node.js是什么,node.js创建应用

    简单的说 Node.js 就是运行在服务端的 JavaScript.Node.js 是一个基于Chrome JavaScript 运行时建立的一个平台.Node.js是一个事件驱动I/O服务端Java ...

  7. angular 自定义服务封装自定义http请求

    在angular中将http请求,放置在一起封装成服务,可减少代码重复,方便使用 var ngpohttprest = angular.module('ngpohttprest', []); ngpo ...

  8. Servlet简单的登陆窗口

    web.xml配置: jsp代码: 注意:action书写的是为这次登陆做处理类的别名,method就是请求的方式 Get请求方式没有请求实体 //如果只是看效果就光写一下service方法就行了 p ...

  9. 利用django打造自己的工作流平台(二):疫情统计系统

    相关文章: 利用django打造自己的工作流平台(一):从EXCEL到流程化运作 本文是“利用django打造自己的工作流平台”系列文章的第二篇,在自己开发的工作流平台中添加了一个用于排查统计可能受感 ...

  10. 「SP11470」TTM - To the moon

    题目描述 给定一段长度为 \(N\) 的序列 \(a\) 以及 \(M\) 次操作,操作有以下几种: C l r d :将区间 \([l,r]\) 中的数都加上 \(d\) Q l r :查询当前时间 ...