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

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

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

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

c = A("c")
h = B("h")
j = C("j")
k = D("k")

c.r = h
h.s = k
j.o = k
j.v = c
j.q = c
j.r = c
k.t = j
k.r = j
assert h.s.t.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

c = A("c")
h = B("h")
j = C("j")
k = D("k")

c.r = h
h.s = k
j.o = k
j.v = c
j.q = c
j.r = c
k.t = j
k.r = j
assert h.s.t.o.r.txt == "j"