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

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

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

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

j = A("j")
k = B("k")
c = C("c")
d = D("d")
h = D("h")

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

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

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

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

j = A("j")
k = B("k")
c = C("c")
d = D("d")
h = D("h")

j.w = d
j.v = k
k.r = j
c.q = k
c.z = k
c.t = j
d.y = j
d.t = j
d.w = h
d.u = c
h.y = j
h.t = j
h.w = d
h.u = c
assert h.t.w.y.txt == "j"