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

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

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

k = A("k")
b = B("b")
h = C("h")
n = A("n")
f = B("f")
j = C("j")
g = B("g")

k.x = g
k.u = j
k.r = n
b.q = n
b.s = f
b.o = f
h.y = b
n.x = b
n.u = j
n.r = k
f.q = k
f.s = b
f.o = b
j.y = f
g.q = n
g.s = f
g.o = b
assert f.q.x.o.q.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.u: C = None
        self.r: A = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
h = C("h")
n = A("n")
f = B("f")
j = C("j")
g = B("g")

k.x = g
k.u = j
k.r = n
b.q = n
b.s = f
b.o = f
h.y = b
n.x = b
n.u = j
n.r = k
f.q = k
f.s = b
f.o = b
j.y = f
g.q = n
g.s = f
g.o = b
assert f.q.x.o.q.x.s.txt == "f"