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

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: E = None
        self.x: A = 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.t: A = None
        self.y: A = None
        self.q: D = None
        self.txt = txt

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

e.s = d
f.s = a
g.u = d
g.w = a
g.x = e
d.q = g
a.t = e
a.y = e
a.q = d
assert a.q.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: E = None
        self.x: A = 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.t: A = None
        self.y: A = None
        self.q: D = None
        self.txt = txt

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

e.s = d
f.s = a
g.u = d
g.w = a
g.x = e
d.q = g
a.t = e
a.y = e
a.q = d
assert a.q.q.u.txt == "d"