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

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

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

l = A("l")
g = B("g")
i = C("i")
j = A("j")
b = B("b")

l.w = i
l.v = i
l.p = i
g.v = b
i.v = l
j.w = i
j.v = i
j.p = i
b.v = g
assert g.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: C = None
        self.p: C = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
i = C("i")
j = A("j")
b = B("b")

l.w = i
l.v = i
l.p = i
g.v = b
i.v = l
j.w = i
j.v = i
j.p = i
b.v = g
assert g.v.v.v.v.txt == "g"