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.x: A = None
        self.txt = txt

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

b = A("b")
l = B("l")
a = C("a")
i = C("i")
n = B("n")
g = A("g")
f = B("f")

b.v = g
b.w = g
l.x = b
a.w = l
a.p = i
i.w = n
i.p = a
n.x = g
g.v = b
g.w = b
f.x = b
assert b.w.w.v.w.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.x: A = None
        self.txt = txt

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

b = A("b")
l = B("l")
a = C("a")
i = C("i")
n = B("n")
g = A("g")
f = B("f")

b.v = g
b.w = g
l.x = b
a.w = l
a.p = i
i.w = n
i.p = a
n.x = g
g.v = b
g.w = b
f.x = b
assert b.w.w.v.w.txt == "b"