class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

b = A("b")
m = B("m")
g = A("g")
j = A("j")
c = B("c")
h = A("h")
e = B("e")
n = A("n")

b.v = n
b.w = h
m.z = j
g.v = n
g.w = n
j.v = h
j.w = h
c.z = j
h.v = n
h.w = n
e.z = b
n.v = b
n.w = h
assert e.z.v.w.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

b = A("b")
m = B("m")
g = A("g")
j = A("j")
c = B("c")
h = A("h")
e = B("e")
n = A("n")

b.v = n
b.w = h
m.z = j
g.v = n
g.w = n
j.v = h
j.w = h
c.z = j
h.v = n
h.w = n
e.z = b
n.v = b
n.w = h
assert e.z.v.w.v.v.txt == "b"