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

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

b = A("b")
k = B("k")
d = B("d")
a = B("a")
c = A("c")
e = B("e")
n = B("n")

b.z = c
b.w = a
k.t = d
k.w = b
d.t = k
d.w = b
a.t = d
a.w = b
c.z = b
c.w = a
e.t = n
e.w = c
n.t = a
n.w = c
assert n.t.w.z.w.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.w: B = None
        self.txt = txt

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

b = A("b")
k = B("k")
d = B("d")
a = B("a")
c = A("c")
e = B("e")
n = B("n")

b.z = c
b.w = a
k.t = d
k.w = b
d.t = k
d.w = b
a.t = d
a.w = b
c.z = b
c.w = a
e.t = n
e.w = c
n.t = a
n.w = c
assert n.t.w.z.w.w.z.txt == "c"