class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: E = None
        self.x: B = None
        self.y: A = None
        self.r: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

n = A("n")
f = B("f")
m = C("m")
h = D("h")
j = E("j")
c = E("c")
d = B("d")
i = B("i")

n.o = h
f.v = n
m.v = c
m.x = d
m.y = n
m.r = n
h.w = d
j.p = n
j.s = n
c.p = n
c.s = n
d.v = n
i.v = n
assert c.s.o.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: E = None
        self.x: B = None
        self.y: A = None
        self.r: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

n = A("n")
f = B("f")
m = C("m")
h = D("h")
j = E("j")
c = E("c")
d = B("d")
i = B("i")

n.o = h
f.v = n
m.v = c
m.x = d
m.y = n
m.r = n
h.w = d
j.p = n
j.s = n
c.p = n
c.s = n
d.v = n
i.v = n
assert c.s.o.w.v.txt == "n"