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

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

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

i = A("i")
d = B("d")
h = C("h")
j = B("j")
k = C("k")
c = A("c")
n = C("n")

i.p = n
i.v = k
d.u = j
d.o = c
d.w = k
h.w = k
h.u = i
j.u = d
j.o = i
j.w = k
k.w = n
k.u = i
c.p = n
c.v = k
n.w = k
n.u = c
assert d.u.o.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: C = None
        self.txt = txt

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

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

i = A("i")
d = B("d")
h = C("h")
j = B("j")
k = C("k")
c = A("c")
n = C("n")

i.p = n
i.v = k
d.u = j
d.o = c
d.w = k
h.w = k
h.u = i
j.u = d
j.o = i
j.w = k
k.w = n
k.u = i
c.p = n
c.v = k
n.w = k
n.u = c
assert d.u.o.p.u.txt == "c"