// File: tanakh[P]icfpc2015/main.cpp
// Function: put_unit(std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::complex<int> const&, unit const&, int, int)
pair<int,int> put_unit(vector<vector<int>> &bd, const pt &pos, const unit &u, int rot, int ls_old)
{
  for (auto &c: u.members) {
    pt p = pos + rot_pivot(c, u.pivot, rot);
    assert(p.imag()>=0&&p.imag()<bd.size()&&p.real()>=0&&p.real()<bd[0].size());
    bd[p.imag()][p.real()] = 1;
  }

  int w = bd[0].size()/2, h = bd.size();
  int cy = h - 1;
  int lines = 0;

  for (int y = h - 1; y >= 0; y--) {
    bool all = true;
    for (int x = 0; x < w; x++) {
      if (bd[y][x*2+y%2] == 0) {
        all = false;
        break;
      }
    }

    if (all) {
      lines++;
    }
    else {
      if (cy != y) {
        for (int x = 0; x < w; x++)
          bd[cy][x*2+cy%2] = bd[y][x*2+y%2];
      }
      cy--;
    }
  }

  while (cy >= 0) {
    for (int x = 0; x < w; x++)
      bd[cy][x*2+cy%2] = 0;
    cy--;
  }

  int points = u.members.size() + 100 * (1 + lines) * lines / 2;
  int bonus = ls_old > 1 ? points * (ls_old - 1) / 10 : 0;

  return make_pair(points + bonus, lines);
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xd8(%rsp)
movq %rsi, 0xd0(%rsp)
movq %rdx, 0xc8(%rsp)
movl %ecx, 0xc4(%rsp)
movl %r8d, 0xc0(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x110b0
movq %rax, 0xb0(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x110e0
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x11110
testb $0x1, %al
jne 0x6f96
jmp 0x712e
leaq 0xb0(%rsp), %rdi
callq 0x11150
movq %rax, 0xa0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xa0(%rsp), %rdi
movq 0xc8(%rsp), %rsi
addq $0x18, %rsi
movl 0xc4(%rsp), %edx
callq 0x11830
movq 0x50(%rsp), %rdi
movq %rax, 0x90(%rsp)
leaq 0x90(%rsp), %rsi
callq 0x12100
movq %rax, 0x98(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x11930
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x5f(%rsp)
jl 0x70a5
leaq 0x98(%rsp), %rdi
callq 0x11930
cltq
movq %rax, 0x48(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x12140
movq 0x48(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x5f(%rsp)
jae 0x70a5
leaq 0x98(%rsp), %rdi
callq 0x11920
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x5f(%rsp)
jl 0x70a5
leaq 0x98(%rsp), %rdi
callq 0x11920
cltq
movq %rax, 0x40(%rsp)
movq 0xd8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12160
movq %rax, %rdi
callq 0x12180
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x5f(%rsp)
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0x70af
jmp 0x70b1
jmp 0x70d0
leaq 0x2f416(%rip), %rdi     # 0x364ce
leaq 0x2f453(%rip), %rsi     # 0x36512
movl $0x18e, %edx            # imm = 0x18E
leaq 0x2f450(%rip), %rcx     # 0x3651b
callq 0x4240
movq 0xd8(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x11930
movq 0x30(%rsp), %rdi
movslq %eax, %rsi
callq 0x12160
movq %rax, 0x38(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x11920
movq 0x38(%rsp), %rdi
movslq %eax, %rsi
callq 0x121a0
movl $0x1, (%rax)
leaq 0xb0(%rsp), %rdi
callq 0x11160
jmp 0x6f78
movq 0xd8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12160
movq %rax, %rdi
callq 0x12180
shrq %rax
movl %eax, 0x8c(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x12140
movl %eax, 0x88(%rsp)
movl 0x88(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x84(%rsp)
movl $0x0, 0x80(%rsp)
movl 0x88(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x7c(%rsp)
cmpl $0x0, 0x7c(%rsp)
jl 0x7308
movb $0x1, 0x7b(%rsp)
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0x7208
movq 0xd8(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
callq 0x12160
movq %rax, %rdi
movl 0x74(%rsp), %eax
shll %eax
movl %eax, 0x2c(%rsp)
movl 0x7c(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl 0x2c(%rsp), %eax
addl %edx, %eax
movslq %eax, %rsi
callq 0x121a0
cmpl $0x0, (%rax)
jne 0x71f9
movb $0x0, 0x7b(%rsp)
jmp 0x7208
jmp 0x71fb
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x71a7
testb $0x1, 0x7b(%rsp)
je 0x7225
movl 0x80(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x72f6
movl 0x84(%rsp), %eax
cmpl 0x7c(%rsp), %eax
je 0x72e5
movl $0x0, 0x70(%rsp)
movl 0x70(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0x72e3
movq 0xd8(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
callq 0x12160
movq %rax, %rdi
movl 0x70(%rsp), %eax
shll %eax
movl %eax, 0x20(%rsp)
movl 0x7c(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl 0x20(%rsp), %eax
addl %edx, %eax
movslq %eax, %rsi
callq 0x121a0
movl (%rax), %eax
movl %eax, 0x28(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0x84(%rsp), %rsi
callq 0x12160
movq %rax, %rdi
movl 0x70(%rsp), %eax
shll %eax
movl %eax, 0x24(%rsp)
movl 0x84(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl 0x24(%rsp), %eax
addl %edx, %eax
movslq %eax, %rsi
callq 0x121a0
movl 0x28(%rsp), %ecx
movl %ecx, (%rax)
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x723e
jmp 0x72e5
movl 0x84(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x72f8
movl 0x7c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x718f
jmp 0x730a
cmpl $0x0, 0x84(%rsp)
jl 0x7391
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0x737b
movq 0xd8(%rsp), %rdi
movslq 0x84(%rsp), %rsi
callq 0x12160
movq %rax, %rdi
movl 0x6c(%rsp), %eax
shll %eax
movl %eax, 0x1c(%rsp)
movl 0x84(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl 0x1c(%rsp), %eax
addl %edx, %eax
movslq %eax, %rsi
callq 0x121a0
movl $0x0, (%rax)
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x731c
movl 0x84(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x730a
movq 0xc8(%rsp), %rdi
callq 0x121c0
movq %rax, 0x10(%rsp)
movl 0x80(%rsp), %eax
addl $0x1, %eax
imull $0x64, %eax, %eax
imull 0x80(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq 0x10(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movl %eax, 0x68(%rsp)
cmpl $0x1, 0xc0(%rsp)
jle 0x73fa
movl 0x68(%rsp), %eax
movl 0xc0(%rsp), %ecx
subl $0x1, %ecx
imull %ecx, %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, 0xc(%rsp)
jmp 0x7402
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x7402
movl 0xc(%rsp), %eax
movl %eax, 0x64(%rsp)
movl 0x68(%rsp), %eax
addl 0x64(%rsp), %eax
movl %eax, 0x60(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x121e0
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
addq $0xe8, %rsp
retq