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

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

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

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

a = A("a")
i = B("i")
f = C("f")
e = D("e")

a.q = f
a.y = f
a.v = e
a.x = i
i.o = e
i.y = a
i.q = f
f.p = e
f.s = e
e.q = a
e.u = f
assert i.q.p.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: D = None
        self.x: B = None
        self.y: C = None
        self.txt = txt

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

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

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

a = A("a")
i = B("i")
f = C("f")
e = D("e")

a.q = f
a.y = f
a.v = e
a.x = i
i.o = e
i.y = a
i.q = f
f.p = e
f.s = e
e.q = a
e.u = f
assert i.q.p.u.p.txt == "e"