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

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

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

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

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

h.p = k
e.p = f
e.x = c
k.w = b
b.w = l
b.q = k
b.x = m
b.v = f
f.p = m
f.x = c
m.p = e
m.x = c
j.w = l
j.q = k
j.x = m
j.v = f
l.p = k
c.w = h
c.q = k
c.x = e
c.v = f
assert l.p.w.x.p.x.x.x.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

h.p = k
e.p = f
e.x = c
k.w = b
b.w = l
b.q = k
b.x = m
b.v = f
f.p = m
f.x = c
m.p = e
m.x = c
j.w = l
j.q = k
j.x = m
j.v = f
l.p = k
c.w = h
c.q = k
c.x = e
c.v = f
assert l.p.w.x.p.x.x.x.q.w.txt == "b"