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

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

g = A("g")
c = B("c")
a = A("a")
l = A("l")
i = B("i")
m = A("m")
d = A("d")
e = A("e")
k = B("k")

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

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

g = A("g")
c = B("c")
a = A("a")
l = A("l")
i = B("i")
m = A("m")
d = A("d")
e = A("e")
k = B("k")

g.s = k
g.r = c
c.p = i
c.q = k
a.s = c
a.r = k
l.s = k
l.r = k
i.p = k
i.q = k
m.s = k
m.r = c
d.s = k
d.r = k
e.s = k
e.r = c
k.p = c
k.q = c
assert e.r.q.p.q.txt == "k"