class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: D = None
        self.p: D = None
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: B = None
        self.s: B = None
        self.u: C = None
        self.txt = txt

d = A("d")
h = B("h")
l = C("l")
b = D("b")
g = B("g")
f = A("f")
j = B("j")
a = D("a")

d.z = h
d.x = a
d.p = b
d.r = l
h.u = a
h.x = a
h.s = j
h.q = l
l.w = j
b.x = a
b.y = h
b.s = j
b.u = l
g.u = a
g.s = j
g.q = l
g.x = b
f.z = h
f.x = a
f.p = b
f.r = l
j.u = b
j.s = g
j.q = l
j.x = a
a.x = b
a.y = g
a.s = g
a.u = l
assert h.s.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: D = None
        self.p: D = None
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: B = None
        self.s: B = None
        self.u: C = None
        self.txt = txt

d = A("d")
h = B("h")
l = C("l")
b = D("b")
g = B("g")
f = A("f")
j = B("j")
a = D("a")

d.z = h
d.x = a
d.p = b
d.r = l
h.u = a
h.x = a
h.s = j
h.q = l
l.w = j
b.x = a
b.y = h
b.s = j
b.u = l
g.u = a
g.s = j
g.q = l
g.x = b
f.z = h
f.x = a
f.p = b
f.r = l
j.u = b
j.s = g
j.q = l
j.x = a
a.x = b
a.y = g
a.s = g
a.u = l
assert h.s.s.q.txt == "l"