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

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

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

a = A("a")
l = B("l")
m = C("m")
g = C("g")
b = C("b")

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

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

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

a = A("a")
l = B("l")
m = C("m")
g = C("g")
b = C("b")

a.p = m
a.x = l
a.w = g
l.t = g
l.w = a
m.t = g
g.t = m
b.t = m
assert l.w.w.t.t.txt == "g"