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

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

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

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

h.z = l
h.p = g
h.r = k
m.t = h
m.u = f
c.t = f
n.z = f
n.p = i
n.r = k
g.t = h
g.u = f
k.t = h
k.u = c
f.t = l
l.t = f
i.t = n
i.u = f
j.t = n
j.u = l
assert l.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: B = None
        self.r: B = None
        self.txt = txt

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

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

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

h.z = l
h.p = g
h.r = k
m.t = h
m.u = f
c.t = f
n.z = f
n.p = i
n.r = k
g.t = h
g.u = f
k.t = h
k.u = c
f.t = l
l.t = f
i.t = n
i.u = f
j.t = n
j.u = l
assert l.t.t.t.t.t.t.txt == "l"