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

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

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

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

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

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

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

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

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