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

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

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

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

i = A("i")
h = B("h")
j = C("j")
k = D("k")
n = B("n")
m = D("m")

i.q = h
i.s = j
h.u = i
h.t = k
h.v = n
j.w = h
j.t = i
k.v = n
k.u = h
k.t = m
k.q = j
n.u = i
n.t = k
n.v = h
m.v = n
m.u = h
m.t = k
m.q = j
assert j.w.t.v.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: C = None
        self.txt = txt

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

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

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

i = A("i")
h = B("h")
j = C("j")
k = D("k")
n = B("n")
m = D("m")

i.q = h
i.s = j
h.u = i
h.t = k
h.v = n
j.w = h
j.t = i
k.v = n
k.u = h
k.t = m
k.q = j
n.u = i
n.t = k
n.v = h
m.v = n
m.u = h
m.t = k
m.q = j
assert j.w.t.v.t.q.txt == "j"