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

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

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

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

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

j.p = n
d.t = j
d.u = f
d.v = n
e.r = j
e.y = j
n.p = j
n.u = e
n.q = e
n.w = f
f.t = j
f.u = d
f.v = n
assert n.w.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

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

j.p = n
d.t = j
d.u = f
d.v = n
e.r = j
e.y = j
n.p = j
n.u = e
n.q = e
n.w = f
f.t = j
f.u = d
f.v = n
assert n.w.t.p.txt == "n"