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

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

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

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

f = A("f")
e = B("e")
m = C("m")
b = D("b")
l = A("l")
j = C("j")
d = C("d")

f.p = b
f.y = e
f.w = e
e.s = b
m.s = j
m.t = l
m.q = e
b.o = j
b.v = d
b.y = m
b.z = l
l.p = b
l.y = e
l.w = e
j.s = m
j.t = l
j.q = e
d.s = m
d.t = f
d.q = e
assert f.p.o.s.q.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.y: B = None
        self.w: B = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
m = C("m")
b = D("b")
l = A("l")
j = C("j")
d = C("d")

f.p = b
f.y = e
f.w = e
e.s = b
m.s = j
m.t = l
m.q = e
b.o = j
b.v = d
b.y = m
b.z = l
l.p = b
l.y = e
l.w = e
j.s = m
j.t = l
j.q = e
d.s = m
d.t = f
d.q = e
assert f.p.o.s.q.s.y.txt == "m"