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

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

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

c = A("c")
n = B("n")
b = C("b")
k = B("k")
g = B("g")
l = C("l")
d = C("d")
a = A("a")

c.r = a
c.y = d
n.q = d
n.s = k
n.z = k
b.y = l
k.q = b
k.s = n
k.z = g
g.q = b
g.s = k
g.z = k
l.y = d
d.y = b
a.r = c
a.y = l
assert k.q.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: C = None
        self.txt = txt

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

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

c = A("c")
n = B("n")
b = C("b")
k = B("k")
g = B("g")
l = C("l")
d = C("d")
a = A("a")

c.r = a
c.y = d
n.q = d
n.s = k
n.z = k
b.y = l
k.q = b
k.s = n
k.z = g
g.q = b
g.s = k
g.z = k
l.y = d
d.y = b
a.r = c
a.y = l
assert k.q.y.y.y.txt == "b"