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

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

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

f = A("f")
j = B("j")
i = C("i")
k = C("k")
e = A("e")
g = B("g")

f.z = k
f.y = e
j.y = g
i.s = g
k.s = j
e.z = i
e.y = f
g.y = j
assert i.s.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: A = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
i = C("i")
k = C("k")
e = A("e")
g = B("g")

f.z = k
f.y = e
j.y = g
i.s = g
k.s = j
e.z = i
e.y = f
g.y = j
assert i.s.y.y.y.y.y.txt == "j"