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

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: D = None
        self.txt = txt

l = A("l")
g = B("g")
e = C("e")
d = D("d")
f = D("f")
n = D("n")
m = A("m")
h = C("h")

l.v = m
l.w = n
g.p = m
g.z = m
g.s = m
g.u = m
e.p = m
e.o = l
d.w = e
d.r = n
f.w = h
f.r = d
n.w = e
n.r = f
m.v = l
m.w = f
h.p = l
h.o = l
assert f.w.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: D = None
        self.txt = txt

l = A("l")
g = B("g")
e = C("e")
d = D("d")
f = D("f")
n = D("n")
m = A("m")
h = C("h")

l.v = m
l.w = n
g.p = m
g.z = m
g.s = m
g.u = m
e.p = m
e.o = l
d.w = e
d.r = n
f.w = h
f.r = d
n.w = e
n.r = f
m.v = l
m.w = f
h.p = l
h.o = l
assert f.w.p.v.txt == "m"