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

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

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

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

c = A("c")
k = B("k")
j = C("j")
d = D("d")
f = D("f")
e = A("e")
a = A("a")
g = B("g")

c.p = j
k.p = a
k.s = g
k.z = g
k.t = j
j.x = f
j.w = g
j.y = g
d.s = f
d.w = f
d.r = e
d.x = k
f.s = d
f.w = d
f.r = c
f.x = g
e.p = j
a.p = j
g.p = a
g.s = k
g.z = k
g.t = j
assert f.w.s.s.x.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
j = C("j")
d = D("d")
f = D("f")
e = A("e")
a = A("a")
g = B("g")

c.p = j
k.p = a
k.s = g
k.z = g
k.t = j
j.x = f
j.w = g
j.y = g
d.s = f
d.w = f
d.r = e
d.x = k
f.s = d
f.w = d
f.r = c
f.x = g
e.p = j
a.p = j
g.p = a
g.s = k
g.z = k
g.t = j
assert f.w.s.s.x.p.p.txt == "j"