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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: A = None
        self.w: C = None
        self.txt = txt

f = A("f")
m = B("m")
j = C("j")
k = D("k")
l = D("l")
e = A("e")
h = D("h")
a = D("a")

f.p = e
m.x = h
j.p = m
k.y = m
k.o = f
k.w = j
l.y = m
l.o = e
l.w = j
e.p = f
h.y = m
h.o = e
h.w = j
a.y = m
a.o = f
a.w = j
assert h.o.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.x: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: A = None
        self.w: C = None
        self.txt = txt

f = A("f")
m = B("m")
j = C("j")
k = D("k")
l = D("l")
e = A("e")
h = D("h")
a = D("a")

f.p = e
m.x = h
j.p = m
k.y = m
k.o = f
k.w = j
l.y = m
l.o = e
l.w = j
e.p = f
h.y = m
h.o = e
h.w = j
a.y = m
a.o = f
a.w = j
assert h.o.p.p.p.p.p.p.txt == "e"