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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: B = None
        self.txt = txt

m = A("m")
f = B("f")
g = C("g")
d = D("d")
b = E("b")

m.y = g
f.u = d
g.q = b
d.o = m
d.s = b
b.u = m
b.z = f
assert g.q.u.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: B = None
        self.txt = txt

m = A("m")
f = B("f")
g = C("g")
d = D("d")
b = E("b")

m.y = g
f.u = d
g.q = b
d.o = m
d.s = b
b.u = m
b.z = f
assert g.q.u.y.q.txt == "b"