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

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.s: C = None
        self.p: D = None
        self.o: A = None
        self.v: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: B = None
        self.p: E = None
        self.v: C = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.s: C = None
        self.p: D = None
        self.o: A = None
        self.v: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: B = None
        self.p: E = None
        self.v: C = None
        self.txt = txt

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

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

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