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

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

h = A("h")
c = B("c")
k = A("k")
j = B("j")

h.t = c
h.z = j
c.z = j
k.t = j
k.z = j
j.z = c
assert j.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: B = None
        self.txt = txt

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

h = A("h")
c = B("c")
k = A("k")
j = B("j")

h.t = c
h.z = j
c.z = j
k.t = j
k.z = j
j.z = c
assert j.z.z.z.txt == "c"