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

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

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

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

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

j.u = n
m.x = i
m.t = j
m.q = j
f.o = j
f.p = n
n.v = m
n.p = j
n.s = j
i.o = j
i.p = n
d.o = j
d.p = n
assert d.p.v.q.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

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

j.u = n
m.x = i
m.t = j
m.q = j
f.o = j
f.p = n
n.v = m
n.p = j
n.s = j
i.o = j
i.p = n
d.o = j
d.p = n
assert d.p.v.q.u.v.txt == "m"