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

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

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

l = A("l")
n = B("n")
k = C("k")
g = C("g")

l.s = n
n.y = l
n.o = l
k.q = n
g.q = n
assert k.q.o.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

l = A("l")
n = B("n")
k = C("k")
g = C("g")

l.s = n
n.y = l
n.o = l
k.q = n
g.q = n
assert k.q.o.s.y.txt == "l"