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

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

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

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

l = A("l")
g = B("g")
j = C("j")
d = D("d")

l.w = d
l.y = d
l.q = d
g.t = j
j.p = g
j.u = l
d.t = g
d.w = j
d.s = l
assert j.u.y.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: D = None
        self.q: D = None
        self.txt = txt

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

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

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

l = A("l")
g = B("g")
j = C("j")
d = D("d")

l.w = d
l.y = d
l.q = d
g.t = j
j.p = g
j.u = l
d.t = g
d.w = j
d.s = l
assert j.u.y.t.t.txt == "j"