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

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

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

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

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

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

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