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

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

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

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

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

n = A("n")
b = B("b")
i = C("i")
h = D("h")
m = E("m")
g = E("g")
c = B("c")

n.u = h
n.q = h
n.v = h
b.r = c
i.p = n
i.t = n
i.r = b
i.w = c
i.q = h
h.r = i
h.q = m
h.p = b
h.w = b
h.s = c
m.u = b
m.x = n
m.s = i
m.z = h
m.y = c
g.u = c
g.y = c
g.x = n
g.s = i
g.z = h
c.r = b
assert g.z.p.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.q: D = None
        self.v: D = None
        self.txt = txt

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

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

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

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

n = A("n")
b = B("b")
i = C("i")
h = D("h")
m = E("m")
g = E("g")
c = B("c")

n.u = h
n.q = h
n.v = h
b.r = c
i.p = n
i.t = n
i.r = b
i.w = c
i.q = h
h.r = i
h.q = m
h.p = b
h.w = b
h.s = c
m.u = b
m.x = n
m.s = i
m.z = h
m.y = c
g.u = c
g.y = c
g.x = n
g.s = i
g.z = h
c.r = b
assert g.z.p.r.r.r.txt == "c"