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

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

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

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

a = A("a")
b = B("b")
h = C("h")
n = D("n")

a.s = h
a.y = h
b.o = h
b.t = a
h.q = b
n.o = a
assert n.o.s.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: C = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
h = C("h")
n = D("n")

a.s = h
a.y = h
b.o = h
b.t = a
h.q = b
n.o = a
assert n.o.s.q.t.txt == "a"