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

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

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

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

e.u = g
g.t = c
g.y = e
l.o = e
c.t = g
c.y = e
assert c.t.t.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

e.u = g
g.t = c
g.y = e
l.o = e
c.t = g
c.y = e
assert c.t.t.t.y.txt == "e"