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

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

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

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

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

d.t = j
d.w = j
k.t = j
k.w = d
l.v = j
l.q = j
l.t = k
l.z = d
j.y = d
assert k.w.t.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.w: D = None
        self.txt = txt

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

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

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

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

d.t = j
d.w = j
k.t = j
k.w = d
l.v = j
l.q = j
l.t = k
l.z = d
j.y = d
assert k.w.t.y.w.txt == "j"