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

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

i = A("i")
n = B("n")
l = B("l")
c = B("c")
h = B("h")
d = A("d")

i.z = d
n.x = c
l.x = h
c.x = h
h.x = l
d.z = i
assert i.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

i = A("i")
n = B("n")
l = B("l")
c = B("c")
h = B("h")
d = A("d")

i.z = d
n.x = c
l.x = h
c.x = h
h.x = l
d.z = i
assert i.z.z.z.z.z.txt == "d"