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

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

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

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

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

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

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

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

k.y = b
k.w = c
k.z = c
b.r = c
g.o = i
i.y = b
i.w = b
i.z = c
h.o = k
c.r = b
assert c.r.r.r.txt == "b"