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

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

l = A("l")
f = B("f")
c = A("c")
m = A("m")
e = A("e")
g = B("g")

l.v = e
l.u = f
f.s = g
c.v = e
c.u = f
m.v = c
m.u = f
e.v = c
e.u = g
g.s = f
assert g.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: B = None
        self.txt = txt

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

l = A("l")
f = B("f")
c = A("c")
m = A("m")
e = A("e")
g = B("g")

l.v = e
l.u = f
f.s = g
c.v = e
c.u = f
m.v = c
m.u = f
e.v = c
e.u = g
g.s = f
assert g.s.s.s.s.txt == "g"