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

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

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

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

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

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

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

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

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

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

h.q = g
h.w = f
h.y = e
h.z = d
d.t = h
d.o = g
l.t = h
e.s = a
e.x = g
e.q = b
b.s = a
b.q = a
b.x = d
g.t = f
g.o = d
f.q = g
f.w = h
f.y = e
f.z = d
a.s = b
a.q = b
a.x = g
j.q = g
j.w = f
j.y = a
j.z = d
assert d.t.w.w.txt == "h"