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

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

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

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

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

g.s = c
g.p = c
b.z = l
b.y = m
b.t = k
b.w = j
e.t = i
e.r = f
f.z = i
f.s = i
f.p = i
k.t = i
k.r = f
m.z = b
m.y = b
m.t = j
m.w = j
c.s = g
c.p = g
j.t = f
j.r = i
i.z = f
i.s = f
i.p = f
l.z = m
l.y = b
l.t = e
l.w = j
assert g.p.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: A = None
        self.txt = txt

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

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

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

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

g.s = c
g.p = c
b.z = l
b.y = m
b.t = k
b.w = j
e.t = i
e.r = f
f.z = i
f.s = i
f.p = i
k.t = i
k.r = f
m.z = b
m.y = b
m.t = j
m.w = j
c.s = g
c.p = g
j.t = f
j.r = i
i.z = f
i.s = f
i.p = f
l.z = m
l.y = b
l.t = e
l.w = j
assert g.p.s.s.txt == "c"