시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 204 14 12 15.385%

문제

평범한 방식으로 정렬을 하면, 숫자가 섞여 있는 문자열(string)은 원하는대로 잘 정렬되지 않는다. 예를 들면, xyz100은 xyz2에 앞서는 식으로 말이다. 어떤 프로그램에서는 문자열에 있는 숫자를 숫자로만 취급하여 정렬하는 '노말 정렬'을 사용한다. 다음은 노말 정렬된 예이다.

XYZ001, XYZ2, XYZ003, XYZ08, XYZ23, XYZ100, XYZQ

우리는 노말 정렬을 다음과 같은 두 가지 방법으로 확장하고자 한다.

  1. 대소문자는 구분하지 않고 정렬한다. (대문자 취급)
  2. +,- 부호가 숫자 뒤에 등장하지 않으며, 숫자보다 앞에 등장하면 다음에 나오는 숫자의 일부라고 생각한다.

예를 들면 123+456+7890은 3개의 숫자가 + 부호로 구분되어 있는 것이고, A+003은 A3과 같다.

우리의 정렬을 하려면, (라이브러리 정렬 방식을 사용하지만) 비교 방법은 따로 작성해야 한다. 비교하는 부분을 작성하시오 (두 개의 출력가능한 공백이 없는 ASCII 문자 36~126를 입력으로 받는다)

리턴값은 다음과 같다

  • -1 : 첫번째 문자열이 두번째 문자열보다 앞서는 경우
  • 0: 두 문자열이 같은 순서인 경우
  • 1: 두번째 문자열이 첫번째 문자열보다 앞서는 경우

입력

첫째줄은 데이터 세트 수 N(1 ≤ N ≤ 1000)이 입력으로 들어온다. 각각의 데이터 세트는 한 줄로 구성되어 있으며, 공백으로 구분된 비교할 두 개의 문자열이다.

출력

각각의 데이터 세트에 대해, -1, 0, 1 중 하나의 값을 공백으로 구분하여 한 줄 씩 출력한다.

예제 입력 1

5
x-3 X0001
123-456-7890 123+456+7890
xYz000123J XyZ+123j
#$%^&*[]- abcdefgh
Abc47jKL+00123 ABC+47jkL123

예제 출력 1

-1
1
0
-1
0
W3sicHJvYmxlbV9pZCI6IjI3MDciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIxNzhcdWI5ZDAgXHVjOD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