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

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: B = None
        self.t: B = None
        self.x: D = None
        self.txt = txt

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

c = A("c")
a = B("a")
e = C("e")
g = D("g")

c.q = e
a.v = c
a.y = c
a.o = e
a.s = e
e.w = g
e.x = g
e.q = a
e.t = a
g.o = c
assert g.o.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: B = None
        self.t: B = None
        self.x: D = None
        self.txt = txt

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

c = A("c")
a = B("a")
e = C("e")
g = D("g")

c.q = e
a.v = c
a.y = c
a.o = e
a.s = e
e.w = g
e.x = g
e.q = a
e.t = a
g.o = c
assert g.o.q.w.txt == "g"