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

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

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

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

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

g = A("g")
k = B("k")
e = C("e")
i = D("i")
f = E("f")

g.p = i
k.z = g
k.o = g
k.w = i
e.w = f
e.s = k
i.u = f
i.p = k
i.o = g
f.w = g
f.x = g
f.u = g
f.r = i
f.q = k
assert e.w.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

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

g = A("g")
k = B("k")
e = C("e")
i = D("i")
f = E("f")

g.p = i
k.z = g
k.o = g
k.w = i
e.w = f
e.s = k
i.u = f
i.p = k
i.o = g
f.w = g
f.x = g
f.u = g
f.r = i
f.q = k
assert e.w.r.u.txt == "f"