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

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

c = A("c")
l = B("l")
a = B("a")
b = A("b")
n = B("n")

c.v = b
c.w = b
l.s = b
l.q = n
a.s = b
a.q = n
b.v = c
b.w = c
n.s = c
n.q = l
assert b.v.v.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: A = None
        self.txt = txt

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

c = A("c")
l = B("l")
a = B("a")
b = A("b")
n = B("n")

c.v = b
c.w = b
l.s = b
l.q = n
a.s = b
a.q = n
b.v = c
b.w = c
n.s = c
n.q = l
assert b.v.v.w.v.txt == "b"