시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
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
W3sicHJvYmxlbV9pZCI6IjI3MDciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIxNzhcdWI5ZDAg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