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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: D = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
c = C("c")
n = D("n")
b = E("b")
g = E("g")
a = D("a")
d = C("d")

h.r = a
h.v = d
l.s = h
l.t = n
c.u = d
c.v = g
c.s = b
c.p = n
c.t = h
n.w = h
n.q = b
n.p = l
n.r = l
b.p = g
b.z = l
g.p = b
g.z = l
a.w = h
a.q = b
a.p = l
a.r = l
d.u = c
d.v = b
d.s = g
d.p = n
d.t = h
assert c.p.w.r.r.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: D = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
c = C("c")
n = D("n")
b = E("b")
g = E("g")
a = D("a")
d = C("d")

h.r = a
h.v = d
l.s = h
l.t = n
c.u = d
c.v = g
c.s = b
c.p = n
c.t = h
n.w = h
n.q = b
n.p = l
n.r = l
b.p = g
b.z = l
g.p = b
g.z = l
a.w = h
a.q = b
a.p = l
a.r = l
d.u = c
d.v = b
d.s = g
d.p = n
d.t = h
assert c.p.w.r.r.t.q.txt == "b"