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

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

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

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

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

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

i.p = l
i.s = k
b.o = l
c.o = l
f.p = l
f.s = c
g.o = l
m.p = f
m.s = e
e.o = l
l.p = n
l.s = c
n.p = f
n.s = b
k.o = f
assert l.s.o.p.s.o.p.p.p.s.txt == "c"