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

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

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

e = A("e")
k = B("k")
a = C("a")
f = B("f")
h = A("h")
j = B("j")
m = A("m")
n = C("n")

e.s = m
e.r = m
k.u = h
k.q = f
a.r = j
f.u = h
f.q = k
h.s = m
h.r = m
j.u = e
j.q = f
m.s = h
m.r = e
n.r = k
assert e.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: A = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
a = C("a")
f = B("f")
h = A("h")
j = B("j")
m = A("m")
n = C("n")

e.s = m
e.r = m
k.u = h
k.q = f
a.r = j
f.u = h
f.q = k
h.s = m
h.r = m
j.u = e
j.q = f
m.s = h
m.r = e
n.r = k
assert e.s.s.s.txt == "m"