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

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

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

i = A("i")
h = B("h")
b = C("b")
k = B("k")
m = C("m")
g = C("g")
c = A("c")

i.w = h
h.t = c
b.y = k
b.x = m
k.t = c
m.y = h
m.x = g
g.y = k
g.x = b
c.w = h
assert k.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

i = A("i")
h = B("h")
b = C("b")
k = B("k")
m = C("m")
g = C("g")
c = A("c")

i.w = h
h.t = c
b.y = k
b.x = m
k.t = c
m.y = h
m.x = g
g.y = k
g.x = b
c.w = h
assert k.t.w.t.txt == "c"