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

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

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

class D:
    def __init__(self, txt: str):
        self.u: E = None
        self.o: E = None
        self.p: C = None
        self.r: E = None
        self.x: B = None
        self.txt = txt

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

k = A("k")
c = B("c")
b = C("b")
d = D("d")
a = E("a")
l = B("l")
e = C("e")
g = B("g")

k.u = d
k.p = d
k.t = l
c.q = k
c.x = b
b.x = e
b.u = g
d.u = a
d.o = a
d.r = a
d.p = e
d.x = c
a.w = g
l.q = k
l.x = e
e.x = b
e.u = g
g.q = k
g.x = b
assert c.x.x.u.x.x.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.t: B = None
        self.p: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: E = None
        self.o: E = None
        self.p: C = None
        self.r: E = None
        self.x: B = None
        self.txt = txt

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

k = A("k")
c = B("c")
b = C("b")
d = D("d")
a = E("a")
l = B("l")
e = C("e")
g = B("g")

k.u = d
k.p = d
k.t = l
c.q = k
c.x = b
b.x = e
b.u = g
d.u = a
d.o = a
d.r = a
d.p = e
d.x = c
a.w = g
l.q = k
l.x = e
e.x = b
e.u = g
g.q = k
g.x = b
assert c.x.x.u.x.x.u.q.txt == "k"