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

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

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

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

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

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

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

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

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

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

n.y = m
n.w = f
a.q = n
a.p = b
a.t = f
b.u = m
m.x = n
m.t = f
k.q = n
k.p = f
k.t = f
f.u = m
assert a.p.u.t.u.t.u.txt == "m"