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

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: D = None
        self.v: A = None
        self.s: A = None
        self.txt = txt

g = A("g")
d = B("d")
h = C("h")
i = D("i")
a = B("a")
b = B("b")
c = A("c")
e = C("e")
n = D("n")
f = A("f")

g.p = c
d.p = f
h.w = e
h.t = e
h.p = e
h.y = g
i.t = g
i.s = g
i.o = n
i.v = f
a.p = g
b.p = g
c.p = g
e.w = h
e.t = h
e.p = h
e.y = f
n.t = c
n.v = c
n.o = i
n.s = g
f.p = c
assert a.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: D = None
        self.v: A = None
        self.s: A = None
        self.txt = txt

g = A("g")
d = B("d")
h = C("h")
i = D("i")
a = B("a")
b = B("b")
c = A("c")
e = C("e")
n = D("n")
f = A("f")

g.p = c
d.p = f
h.w = e
h.t = e
h.p = e
h.y = g
i.t = g
i.s = g
i.o = n
i.v = f
a.p = g
b.p = g
c.p = g
e.w = h
e.t = h
e.p = h
e.y = f
n.t = c
n.v = c
n.o = i
n.s = g
f.p = c
assert a.p.p.p.p.p.p.txt == "c"