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

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

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

b = A("b")
f = B("f")
d = C("d")
i = B("i")
m = B("m")
c = B("c")
n = A("n")
a = A("a")

b.p = c
f.v = d
f.u = a
f.o = i
d.y = a
i.v = d
i.u = a
i.o = f
m.v = d
m.u = a
m.o = i
c.v = d
c.u = a
c.o = m
n.p = c
a.p = m
assert n.p.o.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
d = C("d")
i = B("i")
m = B("m")
c = B("c")
n = A("n")
a = A("a")

b.p = c
f.v = d
f.u = a
f.o = i
d.y = a
i.v = d
i.u = a
i.o = f
m.v = d
m.u = a
m.o = i
c.v = d
c.u = a
c.o = m
n.p = c
a.p = m
assert n.p.o.u.p.txt == "m"