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

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

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

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

j = A("j")
a = B("a")
n = C("n")
b = D("b")
m = D("m")
f = C("f")
d = B("d")
g = D("g")

j.s = f
j.z = d
j.y = a
a.r = j
a.o = j
a.y = j
n.p = j
n.r = m
n.x = g
b.y = f
b.q = f
b.x = m
b.w = g
m.y = n
m.q = n
m.x = b
m.w = g
f.p = j
f.r = b
f.x = b
d.r = j
d.o = j
d.y = j
g.y = f
g.q = f
g.x = b
g.w = b
assert j.s.p.z.y.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: B = None
        self.y: B = None
        self.txt = txt

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

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

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

j = A("j")
a = B("a")
n = C("n")
b = D("b")
m = D("m")
f = C("f")
d = B("d")
g = D("g")

j.s = f
j.z = d
j.y = a
a.r = j
a.o = j
a.y = j
n.p = j
n.r = m
n.x = g
b.y = f
b.q = f
b.x = m
b.w = g
m.y = n
m.q = n
m.x = b
m.w = g
f.p = j
f.r = b
f.x = b
d.r = j
d.o = j
d.y = j
g.y = f
g.q = f
g.x = b
g.w = b
assert j.s.p.z.y.z.r.z.txt == "d"