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

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

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

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

j = A("j")
g = B("g")
f = C("f")
a = D("a")

j.q = g
j.s = f
g.s = a
g.p = a
g.o = f
g.x = j
f.v = g
f.p = a
f.z = a
a.p = f
a.w = j
assert j.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: C = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
f = C("f")
a = D("a")

j.q = g
j.s = f
g.s = a
g.p = a
g.o = f
g.x = j
f.v = g
f.p = a
f.z = a
a.p = f
a.w = j
assert j.q.x.q.txt == "g"