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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

n = A("n")
j = B("j")
a = C("a")
b = D("b")
g = E("g")
l = B("l")
k = D("k")
m = A("m")

n.u = m
j.x = n
j.r = g
a.q = k
a.t = b
a.w = g
a.x = j
b.q = l
b.y = n
g.v = b
l.x = m
l.r = g
k.q = l
k.y = n
m.u = n
assert a.x.r.v.q.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

n = A("n")
j = B("j")
a = C("a")
b = D("b")
g = E("g")
l = B("l")
k = D("k")
m = A("m")

n.u = m
j.x = n
j.r = g
a.q = k
a.t = b
a.w = g
a.x = j
b.q = l
b.y = n
g.v = b
l.x = m
l.r = g
k.q = l
k.y = n
m.u = n
assert a.x.r.v.q.x.u.txt == "n"