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

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

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

e = A("e")
g = B("g")
d = C("d")
l = B("l")

e.y = g
g.o = e
g.y = e
d.z = e
d.r = l
l.o = e
l.y = e
assert g.y.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
d = C("d")
l = B("l")

e.y = g
g.o = e
g.y = e
d.z = e
d.r = l
l.o = e
l.y = e
assert g.y.y.o.txt == "e"