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

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

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

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

h = A("h")
l = B("l")
j = C("j")
b = D("b")
d = C("d")
m = D("m")
k = A("k")
f = C("f")

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

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

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

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

h = A("h")
l = B("l")
j = C("j")
b = D("b")
d = C("d")
m = D("m")
k = A("k")
f = C("f")

h.q = l
h.z = m
l.x = j
l.t = j
j.r = b
j.t = l
j.y = k
b.t = l
b.y = k
b.s = k
b.o = h
d.r = b
d.t = l
d.y = h
m.t = l
m.y = k
m.s = k
m.o = k
k.q = l
k.z = b
f.r = m
f.t = l
f.y = h
assert d.t.x.y.q.txt == "l"