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

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

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

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

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

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

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

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

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

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

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

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

f.y = i
f.o = g
b.p = m
b.s = g
b.v = f
b.q = i
g.u = i
m.z = i
m.o = i
m.u = b
m.v = f
i.x = g
assert g.u.x.u.txt == "i"