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

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

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

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

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

d = A("d")
e = B("e")
j = C("j")
m = D("m")
i = E("i")

d.o = i
d.r = j
d.x = j
d.q = e
e.s = i
e.r = m
j.x = d
j.q = i
j.z = e
j.v = m
j.y = m
m.x = i
m.s = j
i.x = d
i.q = d
i.r = j
assert d.r.x.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.r: C = None
        self.q: B = None
        self.x: C = None
        self.txt = txt

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

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

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

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

d = A("d")
e = B("e")
j = C("j")
m = D("m")
i = E("i")

d.o = i
d.r = j
d.x = j
d.q = e
e.s = i
e.r = m
j.x = d
j.q = i
j.z = e
j.v = m
j.y = m
m.x = i
m.s = j
i.x = d
i.q = d
i.r = j
assert d.r.x.o.q.txt == "d"