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

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

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

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

m = A("m")
i = B("i")
a = C("a")
b = D("b")
d = D("d")
f = B("f")

m.y = a
m.p = b
i.u = a
a.q = f
a.x = d
a.s = d
a.p = b
b.s = m
b.y = d
b.q = d
d.s = m
d.y = b
d.q = b
f.u = a
assert d.s.p.q.q.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: D = None
        self.txt = txt

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

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

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

m = A("m")
i = B("i")
a = C("a")
b = D("b")
d = D("d")
f = B("f")

m.y = a
m.p = b
i.u = a
a.q = f
a.x = d
a.s = d
a.p = b
b.s = m
b.y = d
b.q = d
d.s = m
d.y = b
d.q = b
f.u = a
assert d.s.p.q.q.q.s.txt == "m"