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

class B:
    def __init__(self, txt: str):
        self.z: 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.r: C = None
        self.txt = txt

h = A("h")
m = B("m")
a = C("a")
l = D("l")

h.o = l
h.q = a
m.z = h
a.t = h
l.r = a
assert a.t.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: 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.r: C = None
        self.txt = txt

h = A("h")
m = B("m")
a = C("a")
l = D("l")

h.o = l
h.q = a
m.z = h
a.t = h
l.r = a
assert a.t.o.r.txt == "a"