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

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

b = A("b")
c = B("c")
j = B("j")
m = A("m")
k = A("k")

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

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

b = A("b")
c = B("c")
j = B("j")
m = A("m")
k = A("k")

b.t = j
c.s = m
c.p = b
j.s = m
j.p = k
m.t = j
k.t = c
assert k.t.s.t.p.t.txt == "c"