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

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

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

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

c = A("c")
d = B("d")
g = C("g")
i = D("i")
a = C("a")

c.s = d
c.y = g
d.x = g
g.w = c
g.o = c
g.q = c
i.u = g
i.s = c
i.z = a
i.p = d
a.w = c
a.o = c
a.q = c
assert a.w.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: C = None
        self.txt = txt

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

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

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

c = A("c")
d = B("d")
g = C("g")
i = D("i")
a = C("a")

c.s = d
c.y = g
d.x = g
g.w = c
g.o = c
g.q = c
i.u = g
i.s = c
i.z = a
i.p = d
a.w = c
a.o = c
a.q = c
assert a.w.y.q.txt == "c"