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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: C = None
        self.w: E = None
        self.t: D = None
        self.txt = txt

i = A("i")
m = B("m")
a = C("a")
n = D("n")
j = E("j")
c = E("c")
e = C("e")

i.u = e
m.y = a
m.v = i
a.w = m
a.s = n
a.r = n
n.r = a
j.q = a
j.w = c
j.t = n
c.q = e
c.w = j
c.t = n
e.w = m
e.s = n
e.r = n
assert j.w.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: C = None
        self.w: E = None
        self.t: D = None
        self.txt = txt

i = A("i")
m = B("m")
a = C("a")
n = D("n")
j = E("j")
c = E("c")
e = C("e")

i.u = e
m.y = a
m.v = i
a.w = m
a.s = n
a.r = n
n.r = a
j.q = a
j.w = c
j.t = n
c.q = e
c.w = j
c.t = n
e.w = m
e.s = n
e.r = n
assert j.w.w.t.txt == "n"