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

class B:
    def __init__(self, txt: str):
        self.v: C = 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.r: B = None
        self.p: A = None
        self.txt = txt

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

m = A("m")
b = B("b")
c = C("c")
g = D("g")
f = E("f")
d = C("d")
a = E("a")
i = A("i")
k = B("k")

m.x = i
b.v = c
c.v = k
g.r = b
g.p = m
f.u = g
f.s = k
d.v = b
a.u = g
a.s = k
i.x = m
k.v = d
assert i.x.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: C = 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.r: B = None
        self.p: A = None
        self.txt = txt

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

m = A("m")
b = B("b")
c = C("c")
g = D("g")
f = E("f")
d = C("d")
a = E("a")
i = A("i")
k = B("k")

m.x = i
b.v = c
c.v = k
g.r = b
g.p = m
f.u = g
f.s = k
d.v = b
a.u = g
a.s = k
i.x = m
k.v = d
assert i.x.x.x.x.x.x.x.x.txt == "i"