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

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

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

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

b.x = l
b.v = g
b.p = a
g.u = f
a.w = g
a.v = l
a.x = b
l.x = b
l.v = g
l.p = f
f.w = g
f.v = b
f.x = b
h.w = g
h.v = l
h.x = b
assert a.x.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.v: B = None
        self.p: C = None
        self.txt = txt

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

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

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

b.x = l
b.v = g
b.p = a
g.u = f
a.w = g
a.v = l
a.x = b
l.x = b
l.v = g
l.p = f
f.w = g
f.v = b
f.x = b
h.w = g
h.v = l
h.x = b
assert a.x.v.u.txt == "f"