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

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

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

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

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

c = A("c")
b = B("b")
g = C("g")
a = D("a")
d = E("d")
f = C("f")
m = B("m")
i = C("i")

c.r = d
b.u = c
b.t = c
g.s = i
g.x = d
g.u = d
g.q = c
g.r = a
a.u = c
d.v = f
d.u = c
d.r = m
d.z = a
d.t = a
f.s = g
f.x = d
f.u = d
f.q = c
f.r = a
m.u = c
m.t = c
i.s = f
i.x = d
i.u = d
i.q = c
i.r = a
assert m.t.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

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

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

c = A("c")
b = B("b")
g = C("g")
a = D("a")
d = E("d")
f = C("f")
m = B("m")
i = C("i")

c.r = d
b.u = c
b.t = c
g.s = i
g.x = d
g.u = d
g.q = c
g.r = a
a.u = c
d.v = f
d.u = c
d.r = m
d.z = a
d.t = a
f.s = g
f.x = d
f.u = d
f.q = c
f.r = a
m.u = c
m.t = c
i.s = f
i.x = d
i.u = d
i.q = c
i.r = a
assert m.t.r.r.txt == "m"