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

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

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

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

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

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

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

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

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

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

a.q = b
a.u = i
a.y = h
a.o = h
i.o = h
i.u = a
i.t = a
b.t = a
h.y = i
assert b.t.u.o.y.txt == "i"