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

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

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

e = A("e")
g = B("g")
i = C("i")
j = B("j")
b = B("b")
a = C("a")

e.q = i
g.z = a
i.y = a
i.z = a
j.z = i
b.z = a
a.y = i
a.z = i
assert j.z.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
i = C("i")
j = B("j")
b = B("b")
a = C("a")

e.q = i
g.z = a
i.y = a
i.z = a
j.z = i
b.z = a
a.y = i
a.z = i
assert j.z.y.y.txt == "i"