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

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

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

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

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

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

l.u = a
l.x = g
a.q = l
a.t = g
g.w = n
g.s = n
g.t = a
n.r = a
n.y = a
b.z = n
b.w = n
b.r = a
b.p = a
assert g.w.y.t.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: C = None
        self.txt = txt

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

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

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

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

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

l.u = a
l.x = g
a.q = l
a.t = g
g.w = n
g.s = n
g.t = a
n.r = a
n.y = a
b.z = n
b.w = n
b.r = a
b.p = a
assert g.w.y.t.s.r.txt == "a"