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

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

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

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

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

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

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

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

n.u = c
i.o = b
i.y = b
i.q = c
c.s = n
c.v = i
b.o = i
b.y = i
b.q = c
h.s = n
h.v = b
assert i.y.o.q.v.y.txt == "b"