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

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

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

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

j = A("j")
n = B("n")
f = C("f")
h = D("h")
d = D("d")
m = C("m")

j.r = m
j.s = d
j.x = n
n.r = j
n.v = h
n.s = f
f.t = m
h.q = j
h.z = d
d.q = j
d.z = h
m.t = f
assert d.z.z.z.q.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: D = None
        self.x: B = None
        self.txt = txt

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

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

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

j = A("j")
n = B("n")
f = C("f")
h = D("h")
d = D("d")
m = C("m")

j.r = m
j.s = d
j.x = n
n.r = j
n.v = h
n.s = f
f.t = m
h.q = j
h.z = d
d.q = j
d.z = h
m.t = f
assert d.z.z.z.q.r.t.txt == "f"