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

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

e = A("e")
f = B("f")
c = B("c")
n = B("n")
l = A("l")

e.v = f
e.p = l
f.s = c
f.x = n
c.s = f
c.x = n
n.s = f
n.x = f
l.v = n
l.p = e
assert c.s.x.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.p: A = None
        self.txt = txt

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

e = A("e")
f = B("f")
c = B("c")
n = B("n")
l = A("l")

e.v = f
e.p = l
f.s = c
f.x = n
c.s = f
c.x = n
n.s = f
n.x = f
l.v = n
l.p = e
assert c.s.x.s.s.txt == "c"