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

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

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

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

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

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

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

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

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

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

f.x = i
f.p = i
b.x = l
b.q = l
b.w = c
b.u = g
k.s = b
k.x = m
k.y = a
l.p = m
i.x = f
i.p = f
a.x = l
a.q = c
a.w = c
a.u = g
c.p = k
g.x = l
g.q = l
g.w = l
g.u = a
d.s = g
d.x = k
d.y = b
m.s = g
m.y = g
m.x = k
assert a.x.p.x.x.x.x.x.x.txt == "m"