class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.w: E = None
        self.p: C = None
        self.u: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.z: C = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.z: C = None
        self.txt = txt

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

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

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