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

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

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

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

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

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

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

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

g.u = l
g.p = n
h.o = n
h.w = k
f.z = k
f.u = l
f.w = g
l.o = g
l.w = f
n.u = h
n.p = g
k.z = f
k.u = d
k.w = n
d.o = n
d.w = k
assert k.u.o.p.p.txt == "n"