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

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

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

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

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

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

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