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

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

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

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

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

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

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

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

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

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

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