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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.r: A = None
        self.z: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: B = None
        self.w: C = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
a = B("a")
j = C("j")
b = D("b")
h = C("h")

c.t = b
a.u = h
a.r = c
a.z = j
j.o = b
j.p = a
j.w = h
j.r = c
b.q = h
h.o = b
h.p = a
h.w = j
h.r = c
assert a.r.t.q.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.r: A = None
        self.z: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: B = None
        self.w: C = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
a = B("a")
j = C("j")
b = D("b")
h = C("h")

c.t = b
a.u = h
a.r = c
a.z = j
j.o = b
j.p = a
j.w = h
j.r = c
b.q = h
h.o = b
h.p = a
h.w = j
h.r = c
assert a.r.t.q.r.t.txt == "b"