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

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

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

c = A("c")
k = B("k")
f = C("f")
g = C("g")
b = C("b")
l = A("l")
i = A("i")
a = A("a")
j = A("j")

c.r = i
c.q = k
k.r = a
k.p = g
f.r = c
f.x = c
g.r = j
g.x = c
b.r = i
b.x = a
l.r = c
l.q = k
i.r = l
i.q = k
a.r = c
a.q = k
j.r = a
j.q = k
assert g.r.r.q.p.r.q.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: B = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
f = C("f")
g = C("g")
b = C("b")
l = A("l")
i = A("i")
a = A("a")
j = A("j")

c.r = i
c.q = k
k.r = a
k.p = g
f.r = c
f.x = c
g.r = j
g.x = c
b.r = i
b.x = a
l.r = c
l.q = k
i.r = l
i.q = k
a.r = c
a.q = k
j.r = a
j.q = k
assert g.r.r.q.p.r.q.r.q.txt == "k"