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

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

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

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

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

b = A("b")
k = B("k")
c = C("c")
l = D("l")
m = E("m")

b.r = l
k.s = l
k.t = m
k.x = c
c.q = k
l.t = m
l.u = b
l.o = b
m.p = l
m.s = c
assert c.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

b = A("b")
k = B("k")
c = C("c")
l = D("l")
m = E("m")

b.r = l
k.s = l
k.t = m
k.x = c
c.q = k
l.t = m
l.u = b
l.o = b
m.p = l
m.s = c
assert c.q.x.q.txt == "k"