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

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

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

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

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

d = A("d")
n = B("n")
b = C("b")
a = D("a")
m = E("m")
j = E("j")
f = B("f")
h = E("h")
e = A("e")
g = A("g")

d.x = j
n.u = j
n.o = f
n.v = f
b.w = g
a.u = d
a.p = b
m.p = f
j.p = n
f.u = m
f.o = n
f.v = n
h.p = n
e.x = h
g.x = j
assert f.o.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

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

d = A("d")
n = B("n")
b = C("b")
a = D("a")
m = E("m")
j = E("j")
f = B("f")
h = E("h")
e = A("e")
g = A("g")

d.x = j
n.u = j
n.o = f
n.v = f
b.w = g
a.u = d
a.p = b
m.p = f
j.p = n
f.u = m
f.o = n
f.v = n
h.p = n
e.x = h
g.x = j
assert f.o.v.v.txt == "n"