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

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

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

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

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

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

n = A("n")
m = B("m")
a = C("a")
l = D("l")
d = E("d")
c = F("c")

n.p = l
n.r = l
n.t = m
m.x = l
m.y = l
a.v = m
l.u = n
d.s = a
d.p = l
c.z = m
c.y = l
assert d.s.v.x.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.t: B = None
        self.txt = txt

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

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

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

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

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

n = A("n")
m = B("m")
a = C("a")
l = D("l")
d = E("d")
c = F("c")

n.p = l
n.r = l
n.t = m
m.x = l
m.y = l
a.v = m
l.u = n
d.s = a
d.p = l
c.z = m
c.y = l
assert d.s.v.x.u.r.u.txt == "n"