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

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

f = A("f")
j = B("j")
l = B("l")
e = B("e")
c = A("c")
i = A("i")
d = B("d")

f.z = c
j.x = i
l.x = f
e.x = c
c.z = i
i.z = f
d.x = i
assert j.x.z.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: A = None
        self.txt = txt

f = A("f")
j = B("j")
l = B("l")
e = B("e")
c = A("c")
i = A("i")
d = B("d")

f.z = c
j.x = i
l.x = f
e.x = c
c.z = i
i.z = f
d.x = i
assert j.x.z.z.z.z.z.z.txt == "i"