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

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

f = A("f")
d = B("d")
j = B("j")
g = B("g")
a = B("a")
n = B("n")

f.s = a
d.z = a
j.z = g
g.z = n
a.z = j
n.z = d
assert g.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

f = A("f")
d = B("d")
j = B("j")
g = B("g")
a = B("a")
n = B("n")

f.s = a
d.z = a
j.z = g
g.z = n
a.z = j
n.z = d
assert g.z.z.z.z.z.z.txt == "n"