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

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

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

a = A("a")
d = B("d")
k = C("k")
h = A("h")
e = B("e")
l = A("l")
b = B("b")

a.s = k
a.r = d
a.q = l
d.t = l
d.z = e
k.q = d
k.v = e
h.s = k
h.r = e
h.q = a
e.t = l
e.z = b
l.s = k
l.r = d
l.q = a
b.t = h
b.z = d
assert h.q.s.v.t.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: B = None
        self.q: A = None
        self.txt = txt

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

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

a = A("a")
d = B("d")
k = C("k")
h = A("h")
e = B("e")
l = A("l")
b = B("b")

a.s = k
a.r = d
a.q = l
d.t = l
d.z = e
k.q = d
k.v = e
h.s = k
h.r = e
h.q = a
e.t = l
e.z = b
l.s = k
l.r = d
l.q = a
b.t = h
b.z = d
assert h.q.s.v.t.q.r.txt == "d"