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

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

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

g = A("g")
e = B("e")
k = C("k")
f = C("f")
n = B("n")
c = C("c")
l = A("l")

g.y = k
e.o = k
k.u = g
f.u = g
n.o = c
c.u = l
l.y = k
assert f.u.y.u.y.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
k = C("k")
f = C("f")
n = B("n")
c = C("c")
l = A("l")

g.y = k
e.o = k
k.u = g
f.u = g
n.o = c
c.u = l
l.y = k
assert f.u.y.u.y.u.y.txt == "k"