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

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

h = A("h")
a = B("a")
f = C("f")
d = D("d")

h.r = d
a.o = f
f.o = d
f.q = a
d.u = f
assert d.u.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

h = A("h")
a = B("a")
f = C("f")
d = D("d")

h.r = d
a.o = f
f.o = d
f.q = a
d.u = f
assert d.u.q.o.q.txt == "a"