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

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

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

a = A("a")
k = B("k")
l = C("l")
f = B("f")
h = C("h")
d = A("d")

a.s = f
k.o = l
k.r = l
k.t = h
l.q = d
l.y = h
l.x = h
f.o = l
f.r = l
f.t = h
h.q = a
h.y = l
h.x = l
d.s = k
assert h.y.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
l = C("l")
f = B("f")
h = C("h")
d = A("d")

a.s = f
k.o = l
k.r = l
k.t = h
l.q = d
l.y = h
l.x = h
f.o = l
f.r = l
f.t = h
h.q = a
h.y = l
h.x = l
d.s = k
assert h.y.q.s.txt == "k"