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

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

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

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

h = A("h")
k = B("k")
j = C("j")
e = D("e")
l = C("l")

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

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

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

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

h = A("h")
k = B("k")
j = C("j")
e = D("e")
l = C("l")

h.u = e
h.v = e
h.p = k
k.w = h
j.q = k
j.r = k
j.w = k
e.p = k
e.z = k
e.w = l
e.t = l
l.q = k
l.r = k
l.w = k
assert h.v.w.q.w.txt == "h"