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

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

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

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

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

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

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

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

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

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

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

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

d.x = c
c.x = a
f.v = n
f.s = d
l.y = n
l.p = n
l.u = m
n.s = c
n.w = l
n.v = f
a.x = c
m.v = n
m.s = d
assert d.x.x.x.x.x.x.x.txt == "c"