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

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

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

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

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

i = A("i")
d = B("d")
k = C("k")
g = D("g")
l = E("l")

i.o = l
d.r = i
d.p = i
d.t = i
d.u = g
k.q = d
k.v = l
k.s = i
g.u = k
l.s = i
l.q = g
assert i.o.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

i = A("i")
d = B("d")
k = C("k")
g = D("g")
l = E("l")

i.o = l
d.r = i
d.p = i
d.t = i
d.u = g
k.q = d
k.v = l
k.s = i
g.u = k
l.s = i
l.q = g
assert i.o.q.u.q.txt == "d"