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

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

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

m = A("m")
e = B("e")
c = C("c")
k = C("k")
d = A("d")
j = B("j")
n = B("n")
f = B("f")
l = A("l")
h = A("h")

m.q = d
e.r = c
e.s = c
e.x = c
c.r = k
c.p = f
k.r = c
k.p = n
d.q = h
j.r = k
j.s = k
j.x = c
n.r = k
n.s = k
n.x = k
f.r = k
f.s = c
f.x = c
l.q = d
h.q = l
assert e.r.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

m = A("m")
e = B("e")
c = C("c")
k = C("k")
d = A("d")
j = B("j")
n = B("n")
f = B("f")
l = A("l")
h = A("h")

m.q = d
e.r = c
e.s = c
e.x = c
c.r = k
c.p = f
k.r = c
k.p = n
d.q = h
j.r = k
j.s = k
j.x = c
n.r = k
n.s = k
n.x = k
f.r = k
f.s = c
f.x = c
l.q = d
h.q = l
assert e.r.r.p.txt == "n"