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

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

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

k = A("k")
b = B("b")
n = C("n")
h = C("h")
c = A("c")

k.y = n
b.s = n
n.o = b
n.y = h
n.x = h
h.o = b
h.y = n
h.x = n
c.y = h
assert c.y.x.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
n = C("n")
h = C("h")
c = A("c")

k.y = n
b.s = n
n.o = b
n.y = h
n.x = h
h.o = b
h.y = n
h.x = n
c.y = h
assert c.y.x.y.y.txt == "n"