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

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: C = None
        self.y: A = None
        self.s: B = None
        self.r: A = None
        self.txt = txt

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

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

h.p = c
h.r = m
h.u = j
h.v = d
m.r = f
m.t = g
g.r = c
n.z = h
n.y = h
n.u = g
n.s = m
n.r = i
f.o = j
f.p = m
f.r = h
d.z = h
d.y = h
d.u = g
d.s = c
d.r = k
j.z = h
j.r = h
j.u = g
j.y = i
j.s = c
i.p = c
i.r = c
i.u = n
i.v = d
c.r = f
c.t = g
k.p = c
k.r = m
k.u = n
k.v = d
assert m.r.p.t.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: B = None
        self.u: D = None
        self.v: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: C = None
        self.y: A = None
        self.s: B = None
        self.r: A = None
        self.txt = txt

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

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

h.p = c
h.r = m
h.u = j
h.v = d
m.r = f
m.t = g
g.r = c
n.z = h
n.y = h
n.u = g
n.s = m
n.r = i
f.o = j
f.p = m
f.r = h
d.z = h
d.y = h
d.u = g
d.s = c
d.r = k
j.z = h
j.r = h
j.u = g
j.y = i
j.s = c
i.p = c
i.r = c
i.u = n
i.v = d
c.r = f
c.t = g
k.p = c
k.r = m
k.u = n
k.v = d
assert m.r.p.t.r.r.txt == "f"