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

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

c = A("c")
a = B("a")
j = A("j")
e = A("e")
l = B("l")
n = A("n")
g = B("g")
f = B("f")

c.w = n
a.w = c
a.v = j
j.w = e
e.w = n
l.w = c
l.v = e
n.w = c
g.w = n
g.v = n
f.w = n
f.v = n
assert l.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

c = A("c")
a = B("a")
j = A("j")
e = A("e")
l = B("l")
n = A("n")
g = B("g")
f = B("f")

c.w = n
a.w = c
a.v = j
j.w = e
e.w = n
l.w = c
l.v = e
n.w = c
g.w = n
g.v = n
f.w = n
f.v = n
assert l.w.w.w.w.w.txt == "c"