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

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

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

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

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

l = A("l")
m = B("m")
f = C("f")
d = D("d")
e = E("e")

l.r = d
l.u = f
l.t = e
m.q = l
m.u = l
m.y = l
f.x = m
d.q = f
e.y = l
e.q = m
e.x = m
e.u = d
assert d.q.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: C = None
        self.t: E = None
        self.txt = txt

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

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

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

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

l = A("l")
m = B("m")
f = C("f")
d = D("d")
e = E("e")

l.r = d
l.u = f
l.t = e
m.q = l
m.u = l
m.y = l
f.x = m
d.q = f
e.y = l
e.q = m
e.x = m
e.u = d
assert d.q.x.y.txt == "l"