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

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

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

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

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

a = A("a")
l = B("l")
j = C("j")
g = D("g")
m = E("m")

a.r = m
l.t = g
l.x = g
l.p = m
j.o = a
j.t = a
g.q = a
g.o = a
g.t = m
g.u = j
g.x = j
m.p = l
m.x = l
m.v = j
assert g.x.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

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

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

a = A("a")
l = B("l")
j = C("j")
g = D("g")
m = E("m")

a.r = m
l.t = g
l.x = g
l.p = m
j.o = a
j.t = a
g.q = a
g.o = a
g.t = m
g.u = j
g.x = j
m.p = l
m.x = l
m.v = j
assert g.x.o.r.txt == "m"