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

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

j = A("j")
b = B("b")
f = B("f")
e = B("e")
h = A("h")
n = B("n")

j.t = h
b.z = h
f.z = j
e.z = j
h.t = j
n.z = j
assert h.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

j = A("j")
b = B("b")
f = B("f")
e = B("e")
h = A("h")
n = B("n")

j.t = h
b.z = h
f.z = j
e.z = j
h.t = j
n.z = j
assert h.t.t.t.t.txt == "h"