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

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

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

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

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

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

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

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

l.x = k
l.u = g
g.y = k
g.o = k
k.w = g
k.p = g
f.x = k
f.u = g
n.x = k
n.u = g
assert k.p.y.w.y.p.txt == "g"