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

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

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

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

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

l.p = a
g.w = f
g.x = f
g.p = b
d.y = g
a.v = b
a.w = d
b.w = g
b.p = g
b.x = f
f.w = b
f.p = b
f.x = b
n.p = e
e.v = f
e.w = d
assert b.x.p.w.x.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

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

l.p = a
g.w = f
g.x = f
g.p = b
d.y = g
a.v = b
a.w = d
b.w = g
b.p = g
b.x = f
f.w = b
f.p = b
f.x = b
n.p = e
e.v = f
e.w = d
assert b.x.p.w.x.p.p.txt == "g"