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

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

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

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

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

a = A("a")
j = B("j")
d = C("d")
e = D("e")
b = E("b")
g = B("g")

a.q = g
a.r = b
a.x = e
j.y = g
j.x = g
d.r = g
e.u = b
e.p = j
e.x = g
e.s = d
b.z = e
b.x = e
b.s = a
b.p = j
g.y = j
g.x = j
assert e.p.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: E = None
        self.x: D = None
        self.txt = txt

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

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

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

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

a = A("a")
j = B("j")
d = C("d")
e = D("e")
b = E("b")
g = B("g")

a.q = g
a.r = b
a.x = e
j.y = g
j.x = g
d.r = g
e.u = b
e.p = j
e.x = g
e.s = d
b.z = e
b.x = e
b.s = a
b.p = j
g.y = j
g.x = j
assert e.p.x.y.txt == "j"