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

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

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

c = A("c")
g = B("g")
k = C("k")
b = C("b")
a = B("a")
n = A("n")

c.o = a
c.u = n
c.s = g
g.r = b
g.s = n
k.x = a
b.x = g
a.r = b
a.s = c
n.o = g
n.u = c
n.s = a
assert n.u.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: A = None
        self.s: B = None
        self.txt = txt

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

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

c = A("c")
g = B("g")
k = C("k")
b = C("b")
a = B("a")
n = A("n")

c.o = a
c.u = n
c.s = g
g.r = b
g.s = n
k.x = a
b.x = g
a.r = b
a.s = c
n.o = g
n.u = c
n.s = a
assert n.u.s.s.txt == "n"