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

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

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

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

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

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

f.w = m
f.v = c
c.y = g
c.w = f
l.w = f
l.v = g
g.y = c
g.w = l
m.w = j
m.v = g
j.w = f
j.v = c
assert c.y.y.w.v.txt == "c"