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

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

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

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

l = A("l")
d = B("d")
b = C("b")
i = D("i")
e = C("e")
n = C("n")
g = C("g")
f = A("f")

l.p = f
l.o = f
l.x = d
d.w = f
d.x = f
d.s = i
b.y = e
i.w = l
e.y = b
n.y = e
g.y = n
f.p = l
f.o = l
f.x = d
assert l.p.p.x.w.o.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: B = None
        self.o: A = None
        self.txt = txt

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

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

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

l = A("l")
d = B("d")
b = C("b")
i = D("i")
e = C("e")
n = C("n")
g = C("g")
f = A("f")

l.p = f
l.o = f
l.x = d
d.w = f
d.x = f
d.s = i
b.y = e
i.w = l
e.y = b
n.y = e
g.y = n
f.p = l
f.o = l
f.x = d
assert l.p.p.x.w.o.x.w.x.txt == "d"