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

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

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

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

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

g = A("g")
i = B("i")
k = C("k")
d = D("d")
m = E("m")
n = D("n")
e = E("e")
f = A("f")

g.y = k
g.p = m
i.u = k
k.w = i
k.s = i
d.p = n
m.v = g
n.p = d
e.v = f
f.y = k
f.p = m
assert d.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: E = None
        self.txt = txt

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

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

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

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

g = A("g")
i = B("i")
k = C("k")
d = D("d")
m = E("m")
n = D("n")
e = E("e")
f = A("f")

g.y = k
g.p = m
i.u = k
k.w = i
k.s = i
d.p = n
m.v = g
n.p = d
e.v = f
f.y = k
f.p = m
assert d.p.p.p.p.p.p.p.p.txt == "d"