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

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

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

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

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

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

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

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

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

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

m.q = l
m.x = e
i.y = e
i.z = c
i.s = c
i.p = g
c.v = m
l.r = b
l.v = b
l.w = i
f.y = e
f.z = c
f.s = c
f.p = g
k.r = b
k.v = b
k.w = f
g.y = m
g.z = c
g.s = c
g.p = i
e.q = l
e.x = m
b.y = m
b.z = c
b.s = c
b.p = g
assert i.y.x.x.q.txt == "l"