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

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

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

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

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

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

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

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

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

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

m.q = a
m.v = a
m.u = i
m.x = i
k.p = a
f.r = e
f.v = m
f.w = b
a.w = i
a.y = e
i.q = a
i.v = a
i.u = b
i.x = b
b.q = a
b.v = a
b.u = i
b.x = i
e.r = f
e.v = b
e.w = b
assert k.p.w.x.txt == "b"