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

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

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

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

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

m = A("m")
h = B("h")
c = C("c")
d = D("d")
g = E("g")
f = B("f")
n = A("n")
e = B("e")
l = D("l")

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

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

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

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

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

m = A("m")
h = B("h")
c = C("c")
d = D("d")
g = E("g")
f = B("f")
n = A("n")
e = B("e")
l = D("l")

m.o = d
m.r = c
m.v = n
m.w = n
h.r = g
c.s = n
c.v = g
d.x = c
d.s = n
d.q = l
d.y = m
g.p = d
f.r = g
n.o = d
n.r = c
n.v = m
n.w = m
e.r = g
l.x = c
l.s = n
l.y = n
l.q = d
assert d.y.v.o.q.x.txt == "c"