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

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

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

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

k.q = n
k.o = f
f.x = e
e.t = g
e.y = h
g.q = n
g.o = f
n.t = g
n.y = g
h.q = e
h.o = f
assert e.t.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: B = None
        self.txt = txt

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

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

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

k.q = n
k.o = f
f.x = e
e.t = g
e.y = h
g.q = n
g.o = f
n.t = g
n.y = g
h.q = e
h.o = f
assert e.t.o.x.txt == "e"