시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 321 61 43 40.952%

문제

농부 후안은 바리스타입니다. 후안은 N × M 크기의 커피 농장을 소유하고 있습니다. 후안은 Q번 농장에 씨앗을 심거나 심은 씨앗의 영양의 합을 확인할 것입니다. 후안은 자신의 농장을 관리해줄 자동화 시스템이 필요합니다. 후안을 도와줍시다. 프로그램은 다음과 같은 두 동작을 수행해야 합니다.

  • 씨앗 심기 : x 좌표가 [x1,x2]에 포함되고 y 좌표가 [y1,y2]에 포함되는 모든 위치에 영양이 d인 씨앗을 1개 심습니다.
  • 씨앗 개수 확인하기 : (x,y) 위치에 심은 씨앗의 영양의 합을 확인합니다.

입력

N, M, Q가 첫 줄에 주어집니다. (1 ≤ N, M ≤ 5000, 0 ≤ Q ≤ 2 × 105)

Q개의 줄 동안 수행해야 하는 동작이 주어집니다.

첫 번째로 주어지는 숫자가 1이면 이는 씨앗을 심는 동작임을 뜻하며, 5개의 수 x1, y1, x2, y2, d가 주어집니다. (1 ≤ x1 ≤ x2 ≤ N, 1 ≤ y1 ≤ y2 ≤ M,  - 109 ≤ d ≤ 109)

첫 번째로 주어지는 숫자가 2이면 이는 씨앗의 영양의 합을 확인하는 동작임을 뜻하며, 2개의 수 xy가 주어집니다. (1 ≤ x ≤ N, 1 ≤ y ≤ M)

출력

모든 씨앗 개수를 확인하는 동작에 대해, 각각의 결과를 한 줄마다 출력합니다.

예제 입력 1

3 5 2
1 1 1 3 5 2
2 3 3

예제 출력 1

2
W3sicHJvYmxlbV9pZCI6IjE1NjQ2IiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHViMThkXHViZDgwIFx1ZDZjNFx1YzU0OFx1Yzc0MCBcdWJjMTRcdWI5YWNcdWMyYTRcdWQwYzBcdWM3ODVcdWIyYzhcdWIyZTQiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YjE4ZFx1YmQ4MCBcdWQ2YzRcdWM1NDhcdWM3NDAgXHViYzE0XHViO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