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

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

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

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

c = A("c")
g = B("g")
i = C("i")
k = D("k")

c.s = g
c.y = i
c.w = i
c.p = i
g.r = i
g.s = c
i.p = k
k.q = g
assert i.p.q.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: C = None
        self.w: C = None
        self.p: C = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
i = C("i")
k = D("k")

c.s = g
c.y = i
c.w = i
c.p = i
g.r = i
g.s = c
i.p = k
k.q = g
assert i.p.q.s.w.txt == "i"