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

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

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

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

l.t = b
l.x = j
j.z = c
f.y = b
f.x = j
k.y = b
k.x = j
b.y = k
b.x = j
h.t = f
h.x = j
m.t = b
m.x = j
c.t = k
c.x = j
n.t = f
n.x = j
assert m.t.x.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: B = None
        self.txt = txt

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

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

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

l.t = b
l.x = j
j.z = c
f.y = b
f.x = j
k.y = b
k.x = j
b.y = k
b.x = j
h.t = f
h.x = j
m.t = b
m.x = j
c.t = k
c.x = j
n.t = f
n.x = j
assert m.t.x.z.x.z.txt == "c"