QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#10499. Matching

統計

We say that a word $s$ is almost equal to a word $r$ if the word $s$ can be transformed into the word $r$ using at most $k$ operations of one of the following types:

  • inserting a letter at the beginning, at the end, or between two existing letters of the word $s$,
  • deleting one of the letters of the word $s$,
  • replacing a letter of the word $s$ with another.

You are given two words $t$ and $p$. Determine whether the word $t$ contains a substring* almost equal to the word $p$.

Input

The first line of the input contains a single integer $k$ ($0 \le k \le 10$), used to define the almost-equality relation of words. The second and third lines of the input contain the words $t$ and $p$, respectively. Each of these words consists of at least one and at most $100\,000$ lowercase English letters.

Output

If the word $t$ does not contain a substring almost equal to the word $p$, output the word NIE in a single line.

Otherwise, output two integers $a, b$ ($1 \le a \le b \le |t|$) in a single line, such that the substring of $t$ starting at position $a$ and ending at position $b$ is almost equal to the word $p$.

Positions in the word are consecutive natural numbers. The leftmost letter is at position 1.

If there are multiple solutions, any of them will be accepted as correct.

Examples

Input 1

1
abcd
abd

Output 1

1 2

Input 2

1
abcd
bde

Output 2

NIE

*For a given word $t = c_1c_2 \dots c_n$, a substring of $t$ is any word of the form $c_a \dots c_b$, where $1 \le a \le b \le n$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.