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

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

j = A("j")
n = B("n")
k = A("k")
i = A("i")

j.w = k
j.t = n
n.z = k
n.u = k
k.w = i
k.t = n
i.w = j
i.t = n
assert j.w.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: B = None
        self.txt = txt

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

j = A("j")
n = B("n")
k = A("k")
i = A("i")

j.w = k
j.t = n
n.z = k
n.u = k
k.w = i
k.t = n
i.w = j
i.t = n
assert j.w.t.z.t.txt == "n"