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

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

g = A("g")
l = B("l")
f = A("f")
c = B("c")
n = A("n")
d = B("d")
m = A("m")
b = A("b")

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

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

g = A("g")
l = B("l")
f = A("f")
c = B("c")
n = A("n")
d = B("d")
m = A("m")
b = A("b")

g.x = m
g.w = f
l.y = g
l.v = d
f.x = m
f.w = m
c.y = n
c.v = l
n.x = f
n.w = m
d.y = f
d.v = l
m.x = n
m.w = n
b.x = m
b.w = n
assert l.y.x.x.txt == "n"