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

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

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

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

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

n.w = c
n.v = m
n.t = m
f.t = c
f.v = d
f.q = m
d.y = j
m.z = j
m.q = j
m.t = f
m.y = c
c.w = n
c.v = m
c.t = m
j.t = n
j.v = d
j.q = m
assert j.q.y.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: D = None
        self.t: D = None
        self.txt = txt

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

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

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

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

n.w = c
n.v = m
n.t = m
f.t = c
f.v = d
f.q = m
d.y = j
m.z = j
m.q = j
m.t = f
m.y = c
c.w = n
c.v = m
c.t = m
j.t = n
j.v = d
j.q = m
assert j.q.y.t.t.txt == "f"