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

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

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

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

m = A("m")
f = B("f")
i = C("i")
b = D("b")
d = C("d")
k = D("k")
l = B("l")
g = B("g")

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

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

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

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

m = A("m")
f = B("f")
i = C("i")
b = D("b")
d = C("d")
k = D("k")
l = B("l")
g = B("g")

m.x = b
m.p = b
f.y = m
f.z = b
i.p = g
i.q = g
i.s = f
i.z = b
b.u = k
d.p = f
d.q = f
d.s = f
d.z = k
k.u = b
l.y = m
l.z = b
g.y = m
g.z = b
assert g.z.u.u.u.u.u.u.u.txt == "k"