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

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

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

k = A("k")
i = B("i")
b = C("b")
h = B("h")
a = B("a")
g = C("g")
l = C("l")

k.q = l
k.r = l
k.u = a
i.q = k
b.s = k
h.q = k
a.q = k
g.s = k
l.s = k
assert g.s.q.s.u.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: B = None
        self.r: C = None
        self.txt = txt

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

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

k = A("k")
i = B("i")
b = C("b")
h = B("h")
a = B("a")
g = C("g")
l = C("l")

k.q = l
k.r = l
k.u = a
i.q = k
b.s = k
h.q = k
a.q = k
g.s = k
l.s = k
assert g.s.q.s.u.q.u.txt == "a"