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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

i = A("i")
g = B("g")
n = C("n")
f = D("f")
k = E("k")
h = C("h")
j = A("j")
l = A("l")
m = B("m")

i.t = f
i.v = f
i.p = k
g.s = i
g.x = m
g.z = f
n.p = m
n.w = i
n.r = g
n.z = f
f.r = k
k.s = m
h.p = g
h.r = g
h.w = l
h.z = f
j.t = f
j.v = f
j.p = k
l.t = f
l.v = f
l.p = k
m.s = j
m.x = g
m.z = f
assert i.t.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: E = None
        self.v: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

i = A("i")
g = B("g")
n = C("n")
f = D("f")
k = E("k")
h = C("h")
j = A("j")
l = A("l")
m = B("m")

i.t = f
i.v = f
i.p = k
g.s = i
g.x = m
g.z = f
n.p = m
n.w = i
n.r = g
n.z = f
f.r = k
k.s = m
h.p = g
h.r = g
h.w = l
h.z = f
j.t = f
j.v = f
j.p = k
l.t = f
l.v = f
l.p = k
m.s = j
m.x = g
m.z = f
assert i.t.r.s.txt == "m"