First repeated occurrence of either'a' or 'b' or 'c' or 'd' X49874


Statement
 

pdf   zip

html

Implement a program such that, given a sequence of characters from {a,b,c,d}, tells which one is the first character that is found repeated when we read them from the beginning, and on what position this first repetition takes place (positions are assumed to be indexed starting from 0).

It is guaranteed that there will be at least one repetition.

Input

The input contains only one line with a sequence of consecutive characters from {a,b,c,d}. It is guaranteed that at least one character occurs twice or more in the input sequence.

Output

The output contains the first character which occurs twice or more in the input, and the position of the first repetition (indexing positions from 0). These data must be printed on one line and separated by a white space.

Observation

Do not use strings nor any other massive data storage method. Read and treat the input character by character. Please, try to avoid carrying on reading the input when that is no longer necessary.

Public test cases
  • Input

    abcdaddcbaabaccdd

    Output

    a 4
    
  • Input

    bbabaaaabb

    Output

    b 1
    
  • Input

    bacdcdba

    Output

    c 4
    
  • Input

    dd

    Output

    d 1
    
  • Information
    Author
    PRO1
    Language
    English
    Translator
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    C++
    User solutions
    C++