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

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

l = A("l")
j = B("j")
m = A("m")
a = B("a")
g = A("g")
c = A("c")

l.u = j
j.w = a
m.u = a
a.w = j
g.u = a
c.u = a
assert c.u.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

l = A("l")
j = B("j")
m = A("m")
a = B("a")
g = A("g")
c = A("c")

l.u = j
j.w = a
m.u = a
a.w = j
g.u = a
c.u = a
assert c.u.w.w.w.w.txt == "a"