INPUT q$
INPUT w$
FOR i = 1 TO LEN(q$)
FOR j = 1 TO LEN(w$)
IF MID$(q$, i, 1) = MID$(w$, j, 1) THEN
IF INSTR(q$, MID$(q$, i, 1)) >= i THEN
PRINT MID$(q$, i, 1)
EXIT FOR
END IF
END IF
NEXT j
NEXT i