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

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

c = A("c")
j = B("j")
m = A("m")
l = A("l")
k = A("k")
b = B("b")
f = B("f")
e = B("e")
i = A("i")

c.t = m
j.p = e
j.s = m
m.t = c
l.t = i
k.t = i
b.p = j
b.s = l
f.p = e
f.s = m
e.p = j
e.s = c
i.t = m
assert m.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

c = A("c")
j = B("j")
m = A("m")
l = A("l")
k = A("k")
b = B("b")
f = B("f")
e = B("e")
i = A("i")

c.t = m
j.p = e
j.s = m
m.t = c
l.t = i
k.t = i
b.p = j
b.s = l
f.p = e
f.s = m
e.p = j
e.s = c
i.t = m
assert m.t.t.t.t.t.t.txt == "m"