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

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

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

k = A("k")
f = B("f")
g = C("g")
a = B("a")
b = C("b")
l = A("l")
e = B("e")
i = C("i")
d = B("d")

k.q = l
f.r = k
f.v = l
g.p = f
g.s = f
g.q = b
a.r = l
a.v = k
b.p = f
b.q = i
b.s = a
l.q = k
e.r = l
e.v = l
i.p = f
i.q = g
i.s = a
d.r = l
d.v = k
assert a.r.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
g = C("g")
a = B("a")
b = C("b")
l = A("l")
e = B("e")
i = C("i")
d = B("d")

k.q = l
f.r = k
f.v = l
g.p = f
g.s = f
g.q = b
a.r = l
a.v = k
b.p = f
b.q = i
b.s = a
l.q = k
e.r = l
e.v = l
i.p = f
i.q = g
i.s = a
d.r = l
d.v = k
assert a.r.q.q.q.q.txt == "l"