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

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: B = None
        self.txt = txt

k = A("k")
b = B("b")
c = A("c")
f = A("f")
m = A("m")
h = A("h")
n = B("n")

k.z = b
k.t = n
b.y = n
b.w = n
c.z = n
c.t = b
f.z = n
f.t = b
m.z = n
m.t = b
h.z = n
h.t = n
n.y = b
n.w = b
assert h.t.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: B = None
        self.txt = txt

k = A("k")
b = B("b")
c = A("c")
f = A("f")
m = A("m")
h = A("h")
n = B("n")

k.z = b
k.t = n
b.y = n
b.w = n
c.z = n
c.t = b
f.z = n
f.t = b
m.z = n
m.t = b
h.z = n
h.t = n
n.y = b
n.w = b
assert h.t.w.w.txt == "n"