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

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

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

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

j.u = n
j.p = e
j.o = f
f.u = n
f.v = n
c.x = j
k.x = j
n.x = d
e.x = d
d.u = c
d.p = c
d.o = g
g.u = k
g.v = c
assert c.x.p.x.u.x.u.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: C = None
        self.o: B = None
        self.txt = txt

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

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

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

j.u = n
j.p = e
j.o = f
f.u = n
f.v = n
c.x = j
k.x = j
n.x = d
e.x = d
d.u = c
d.p = c
d.o = g
g.u = k
g.v = c
assert c.x.p.x.u.x.u.x.o.txt == "g"