Buggy python submission (verdict: Runtime Error):
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()
    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)
    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            



while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])

    B = 0
    W = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W

Fixed submission:
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()

    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)

    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            
import sys
limit = 100000
sys.setrecursionlimit(limit)


while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])
    B = 0
    W = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W

Buggy python submission (verdict: Runtime Error):
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()
    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)
    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            



while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])

    B = 0
    W = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W

Fixed submission:
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()

    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)

    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            
import sys
limit = 100000
sys.setrecursionlimit(limit)


while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])
    B = 0
    W = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W

Buggy python submission (verdict: Runtime Error):
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()

    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)

    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            



while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])
    b = 0
    w = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W

Fixed submission:
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()

    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)

    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            
import sys
limit = 100000
sys.setrecursionlimit(limit)


while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])
    B = 0
    W = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W

Buggy python submission (verdict: Runtime Error):
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()

    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)

    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            



while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])
    B = 0
    W = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W

Fixed submission:
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()

    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)

    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            
import sys
limit = 100000
sys.setrecursionlimit(limit)


while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])
    B = 0
    W = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W